Skip to content

Commit d51f3ad

Browse files
Don't Try to Set a Negative Frame Height (#96)
### Description Fixes a potential recursion where CETV tries to set it's frame to a negative number (due to overscroll & scroll inset weirdness). This adds a super simple sanity check to make sure we limit the textview to a `0` frame at minimum. This hang would occur when no content is present, making the content size an odd number, which also makes scroll views freak out on macOS. ### Related Issues * CodeEditApp/CodeEdit#2049 ### Checklist - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots N/A, fixes a hang.
1 parent d82b1c0 commit d51f3ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/CodeEditTextView/TextView/TextView+Layout.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ extension TextView {
7272
availableSize.height -= (scrollView?.contentInsets.top ?? 0) + (scrollView?.contentInsets.bottom ?? 0)
7373

7474
let extraHeight = availableSize.height * overscrollAmount
75-
let newHeight = max(layoutManager.estimatedHeight() + extraHeight, availableSize.height)
75+
let newHeight = max(layoutManager.estimatedHeight() + extraHeight, availableSize.height, 0)
7676
let newWidth = layoutManager.estimatedWidth()
7777

7878
var didUpdate = false

0 commit comments

Comments
 (0)