mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Optimize replaceAll (#931)
This commit is contained in:
parent
97ca807e40
commit
65214d64a7
@ -9,6 +9,7 @@ Change Log
|
||||
|
||||
- Adjust the text baseline to draw characters vertically center in lines.
|
||||
- Adjust the invisible characters position in the vertical text orientation.
|
||||
- Optimize the performance of “Replace All” with a large number of matches.
|
||||
- Duplicate lines more intelligently.
|
||||
- Use mirrored pilcrow sign “⁋” for an invisible line ending symbol in RTL mode.
|
||||
- Improve drawing performance.
|
||||
|
@ -338,16 +338,16 @@ final class TextFind {
|
||||
length = scopeRange.length
|
||||
} else {
|
||||
// build replacementString
|
||||
var replacedString = (self.string as NSString).substring(with: scopeRange) as NSString
|
||||
let replacedString = NSMutableString(string: (self.string as NSString).substring(with: scopeRange))
|
||||
for item in items.reversed() {
|
||||
block(.replacementProgress, &ioStop)
|
||||
if ioStop { return }
|
||||
|
||||
// -> Do not convert to Range<Index>. It can fail when the range is smaller than String.Character.
|
||||
let substringRange = item.range.shifted(offset: -scopeRange.location)
|
||||
replacedString = replacedString.replacingCharacters(in: substringRange, with: item.string) as NSString
|
||||
replacedString.replaceCharacters(in: substringRange, with: item.string)
|
||||
}
|
||||
replacementItems.append(ReplacementItem(string: replacedString as String, range: scopeRange))
|
||||
replacementItems.append(ReplacementItem(string: replacedString.copy() as! String, range: scopeRange))
|
||||
length = replacedString.length
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user