Fix selection after redo with .balancesBrackets option

This commit is contained in:
1024jp 2018-10-08 16:46:33 +09:00
parent a4fe5acfab
commit 4de7040896
2 changed files with 6 additions and 1 deletions

View File

@ -12,6 +12,11 @@ Change Log
- Adjust width of line number views.
### Fixes
- Fix an issue where the cursor position did not restore correctly after repeatedly undoing & redoing bracket insertion with the “Automatically insert closing brackets and quotes” option enabled.
3.6.1 (288)
--------------------------

View File

@ -353,7 +353,7 @@ final class EditorTextView: NSTextView, CurrentLineHighlighting, Themable {
!(pair.begin == pair.end && CharacterSet.alphanumerics.contains(self.characterBeforeInsertion ?? UnicodeScalar(0))) // for "
{
super.insertText(String(pair.begin) + String(pair.end), replacementRange: replacementRange)
self.selectedRange.location -= 1
self.setSelectedRangesWithUndo([NSRange(location: self.selectedRange.location - 1, length: 0)])
self.textStorage?.addAttribute(.autoBalancedClosingBracket, value: true,
range: NSRange(location: self.selectedRange.location, length: 1))
return