mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Keep text selection after color code insertion
This commit is contained in:
parent
3626be22a8
commit
ccfd850e0d
@ -7,8 +7,9 @@ develop
|
||||
|
||||
### Improvements
|
||||
|
||||
- Tweak preferences layout.
|
||||
- Add dot mark to installed syntax style list in preferences to represent the state if style is customized.
|
||||
- Keep text selection after inserting color code from the color code panel.
|
||||
- Tweak preferences layout.
|
||||
|
||||
|
||||
### Fixes
|
||||
|
@ -180,11 +180,13 @@
|
||||
if (![self colorCode]) { return; }
|
||||
|
||||
NSTextView *textView = [[[self documentWindowController] editor] focusedTextView];
|
||||
NSRange selectedRange = [textView selectedRange];
|
||||
|
||||
if ([textView shouldChangeTextInRange:[textView selectedRange] replacementString:[self colorCode]]) {
|
||||
[textView replaceCharactersInRange:[textView selectedRange] withString:[self colorCode]];
|
||||
if ([textView shouldChangeTextInRange:selectedRange replacementString:[self colorCode]]) {
|
||||
[textView replaceCharactersInRange:selectedRange withString:[self colorCode]];
|
||||
[[textView undoManager] setActionName:NSLocalizedString(@"Insert Color Code", nil)];
|
||||
[textView didChangeText];
|
||||
[textView setSelectedRange:NSMakeRange(selectedRange.location, [[self colorCode] length])];
|
||||
[textView scrollRangeToVisible:[textView selectedRange]];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user