AppKit: Apply font changes without a selection to CPTextView typing attributes

When no text was selected, CPTextView's changeFont: implementation
erroneously extracted the font to convert from the text storage at the
insertion point rather than from current typing attributes. Consequently,
repeated adjustments like Bigger or Smaller failed to accumulate, blank
document font sizing remained locked after one step, and output arguments
risked overwriting selection state.

* AppKit/CPTextView/CPTextView.j:
  - Update changeFont: to derive and convert fonts directly from typing
    attributes when no selection is active, and post corresponding typing
    attribute update notifications.
  - Eliminate selection range output arguments that could inadvertently
    modify active selection bounds.

* Tests/AppKit/CPTextViewTest.j:
  - Add unit tests verifying that repeated font modifications accumulate correctly
    at zero-length insertion points.

* Tests/Manual/TextEditor/WORKLIST.md:
  - Mark Bigger and Smaller actions without a selection as tested.

Bigger and Smaller menu commands now correctly compound font size adjustments for subsequent typed text, matching Cocoa behavior.
This commit is contained in:
David Richardson committed 2026-10-24 12:59:18 -06:00
1 parent 8c30016f3d
commit befbbb9c3b
3 files changed
+34 -4

No files matched your search

+4 -4
View File
@@ -2198,11 +2198,11 @@ Sets the selection to a range of characters in response to user action.
}
else
{
attributes = [_textStorage attributesAtIndex:_selectionRange.location
longestEffectiveRange:_selectionRange
inRange:_selectionRange];
oldFont = [attributes objectForKey:CPFontAttributeName] || [self font];
// As in Cocoa, without a selection the change applies to the typing attributes, so
// repeated changes, such as Bigger, build on each other.
oldFont = [_typingAttributes objectForKey:CPFontAttributeName] || [self font];
[_typingAttributes setObject:[sender convertFont:oldFont] forKey:CPFontAttributeName];
[[CPNotificationCenter defaultCenter] postNotificationName:CPTextViewDidChangeTypingAttributesNotification object:self];
}
}
else