Fix multi-cursor behavior with and with empty selection

This commit is contained in:
1024jp 2019-01-15 19:43:45 +09:00
parent 97de458481
commit ae196f9ad6
2 changed files with 15 additions and 2 deletions

View File

@ -2,6 +2,15 @@
Change Log
==========================
3.7.0-beta.5 (unreleased)
--------------------------
### Fixes
- [beta] Fix multi-cursor behavior with `→` and `←` when something is selected.
3.7.0-beta.4 (327)
--------------------------

View File

@ -38,7 +38,9 @@ extension EditorTextView {
guard self.hasMultipleInsertions else { return super.moveLeft(sender) }
self.moveCursors(affinity: .downstream) { (self.string as NSString).index(before: $0.lowerBound) }
self.moveCursors(affinity: .downstream) {
($0.length == 0) ? (self.string as NSString).index(before: $0.lowerBound) : $0.lowerBound
}
}
@ -62,7 +64,9 @@ extension EditorTextView {
guard self.hasMultipleInsertions else { return super.moveRight(sender) }
self.moveCursors(affinity: .upstream) { (self.string as NSString).index(after: $0.upperBound) }
self.moveCursors(affinity: .upstream) {
($0.length == 0) ? (self.string as NSString).index(after: $0.upperBound) : $0.upperBound
}
}