Improvve auto-quotes with multiple selections

This commit is contained in:
1024jp 2017-03-20 01:02:13 +09:00
parent 354c98954f
commit defda309ff
2 changed files with 3 additions and 8 deletions

View File

@ -24,6 +24,7 @@ develop
- Improve invisible character drawing on a non-opaque view.
- Change syntax style detection behavior to set “None” style if no appropriate style can be found on file opening.
- Remove “Inline script menu items into contextual menu” option.
- Improve auto-brackets/quotes insertion behavior with multiple selections.
- Improve the setting file naming rule for when the name overwraps with an existing setting.
- And some minor improvements and fixes.

View File

@ -290,14 +290,8 @@ final class EditorTextView: NSTextView, Themable {
{
// wrap selection with brackets if some text is selected
if self.selectedRange.length > 0 {
let selectedString = (wholeString as NSString).substring(with: self.selectedRange)
let replacementString = String(pair.begin) + selectedString + String(pair.end)
if self.shouldChangeText(in: self.rangeForUserTextChange, replacementString: replacementString) {
self.replaceCharacters(in: self.rangeForUserTextChange, with: replacementString)
self.didChangeText()
return
}
self.surroundSelections(begin: String(pair.begin), end: String(pair.end))
return
// check if insertion point is in a word
} else if !CharacterSet.alphanumerics.contains(self.characterAfterInsertion ?? UnicodeScalar(0)) {