mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Optimize line ending normalization (fix #1406)
This commit is contained in:
parent
12cec17bd1
commit
7aeecd7ede
@ -7,6 +7,7 @@ Change Log
|
||||
|
||||
### Improvements
|
||||
|
||||
- Optimize the performance of the normalization of incompatible line endings.
|
||||
- [beta][trivial] Add device name to quick actions related to Continuity Camera.
|
||||
- [beta] Localize strings added on CotEditor 4.7.0 to Chinese, Italian, and Turkish.
|
||||
|
||||
|
@ -156,7 +156,10 @@ extension NSMutableAttributedString {
|
||||
/// - lineEnding: The line ending type with which to replace the target.
|
||||
final func replaceLineEndings(with lineEnding: LineEnding) {
|
||||
|
||||
self.mutableString.replaceOccurrences(of: LineEnding.allRegexPattern, with: lineEnding.string, options: .regularExpression, range: self.range)
|
||||
// -> Intentionally avoid replacing characters in the mutableString directly,
|
||||
// because it pots a quantity of small edited notifications,
|
||||
// which costs high. (2023-11, macOS 14)
|
||||
self.replaceCharacters(in: self.range, with: self.string.replacingLineEndings(with: lineEnding))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user