Spport mutli-cursor when inputting in unicode hex

This commit is contained in:
1024jp 2019-04-05 19:41:44 +09:00
parent de63c5b012
commit 2546793618
2 changed files with 15 additions and 8 deletions

View File

@ -2,6 +2,15 @@
Change Log
==========================
3.7.3 (unreleased)
--------------------------
### Improvements
- “Input in unicode hex” now supports multi-cursor editing.
3.7.2 (347)
--------------------------

View File

@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2014-2018 1024jp
// © 2014-2019 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -42,14 +42,12 @@ extension EditorTextView: UnicodeInputReceiver {
/// insert an Unicode character from Unicode input panel
@IBAction func insertUnicodeCharacter(_ sender: UnicodeInputViewController) {
guard let character = sender.characterString else { return }
guard
let character = sender.characterString,
let ranges = self.rangesForUserTextChange as? [NSRange]
else { return }
let range = self.rangeForUserTextChange
if self.shouldChangeText(in: range, replacementString: character) {
self.replaceCharacters(in: range, with: character)
self.didChangeText()
}
self.insertText(character, replacementRanges: ranges)
}
}