mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Register insertionLocations to undoManager more properly
This commit is contained in:
parent
3020d349db
commit
c8c10e2142
@ -7,15 +7,16 @@ Change Log
|
||||
|
||||
### Improvements
|
||||
|
||||
- [beta] Support `^T` and `fn+delete` (`^D`) shortcut multi-cursor editing.
|
||||
- [beta] Support `^T` and `fn+delete` (`^D`) shortcut in multi-cursor editing.
|
||||
|
||||
|
||||
### Fixes
|
||||
|
||||
- [beta] Fix an issue where multiple cursors disappeared after (auto-)saving with “trim tailing whitespace on save” option.
|
||||
- [beta] Fix an issue where multiple cursors disappeared after (auto-)saving with “trim trailing whitespace on save” option.
|
||||
- [beta] Fix an issue where the first cursor could disappear after some specific text editing.
|
||||
- [beta] Fix an issue where auto-inserted tab did not expand to spaces on auto indent level adjustment.
|
||||
- [beta] Fix multi-cursor behavior of deleting to the beginning of visual line by `⌘⌫`.
|
||||
- [beta] Fix multi-cusor movement when encounter a surrogate pair.
|
||||
- [beta] Fix multi-cursor behavior of deleting to the beginning of the visual line by `⌘⌫`.
|
||||
- [beta] Fix multi-cursor movement when encountering a surrogate pair.
|
||||
- [beta] Fix an issue where a selected range and an insertion point could overlap.
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@ extension NSTextView {
|
||||
|
||||
|
||||
textStorage.beginEditing()
|
||||
// use backwards enumeration to skip adjustment of applying location
|
||||
// use a backward enumeration to skip adjustment of applying location
|
||||
for (string, range) in zip(strings, ranges).reversed() {
|
||||
let attrString = NSAttributedString(string: string, attributes: self.typingAttributes)
|
||||
|
||||
@ -87,7 +87,16 @@ extension NSTextView {
|
||||
/// set undoable selection change
|
||||
func setSelectedRangesWithUndo(_ ranges: [NSValue]) {
|
||||
|
||||
self.selectedRanges = ranges
|
||||
if let self = self as? NSTextView & MultiCursorEditing,
|
||||
let ranges = ranges as? [NSRange],
|
||||
let set = self.prepareForSelectionUpdate(ranges)
|
||||
{
|
||||
self.selectedRanges = set.selectedRanges
|
||||
self.insertionLocations = set.insertionLocations
|
||||
|
||||
} else {
|
||||
self.selectedRanges = ranges
|
||||
}
|
||||
|
||||
self.undoManager?.registerUndo(withTarget: self) { target in
|
||||
target.setSelectedRangesWithUndo(ranges)
|
||||
@ -102,7 +111,7 @@ extension NSTextView {
|
||||
}
|
||||
|
||||
|
||||
/// trim all trailing whitespace with/without keeeping editing point
|
||||
/// trim all trailing whitespace with/without keeping editing point
|
||||
func trimTrailingWhitespace(ignoresEmptyLines: Bool, keepingEditingPoint: Bool = false) {
|
||||
|
||||
assert(Thread.isMainThread)
|
||||
|
Loading…
Reference in New Issue
Block a user