AppKit: Fit a tracking text container inside the text view's inset

A text container that tracked its text view's size took the text view's full width, while the text started after the text container inset, so lines could run past the visible right edge.
It now follows Cocoa: a tracking container fills the text view minus the inset on both sides.

* CPTextView/CPTextContainer.j: Subtract the text container inset on both sides when tracking the text view's width and height.

* CPTextView/CPTextView.j: Refit the text container when a text view is created and when its text container inset changes.
This commit is contained in:
David Richardson committed 2026-10-23 19:32:07 -06:00
1 parent 00851abfa9
commit b4bff7ffe1
2 files changed
+12 -3

No files matched your search

+6
View File
@@ -210,6 +210,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
[self _init];
[aContainer setTextView:self];
// Fit a container that tracks the text view's size inside the text container inset.
[aContainer textViewFrameChanged:nil];
[self setEditable:YES];
[self setSelectable:YES];
[self setRichText:NO];
@@ -812,6 +815,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
{
_textContainerInset = aSize;
[self invalidateTextContainerOrigin];
// A container that tracks the text view's size must shrink or grow with the new inset.
[_textContainer textViewFrameChanged:nil];
}
- (void)invalidateTextContainerOrigin