Skip to content

Commit

Permalink
Optimize hunging indentation caluculation (fix #1515, fix #1532)
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Nov 4, 2023
1 parent ec4ddd9 commit 06136f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Change Log
- Optimize the performance of the incompatible character scan.


### Fixes

- Fix an issue that the application could hang when opening a large document without line breaks.



4.6.4 (599)
--------------------------
Expand Down
7 changes: 3 additions & 4 deletions CotEditor/Sources/LineRangeCacheable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ extension LineRangeCacheable {
self.lineRangeCache.lineStartIndexes.insert(index)
}
self.lineRangeCache.parsedIndexes.insert(integersIn: lowerParseBound..<index)
self.lineRangeCache.invalidateFirstUncountedIndex()
self.lineRangeCache.firstUncountedIndex = index
}
}

Expand All @@ -211,12 +211,11 @@ private extension LineRangeCache {


/// Update the first uncounted index.
mutating func invalidateFirstUncountedIndex() {
private mutating func invalidateFirstUncountedIndex() {

let firstInvalidIndex = self.parsedIndexes.contains(0)
? self.parsedIndexes.rangeView.first?.last.flatMap { $0 + 1 } ?? 0
? self.parsedIndexes.rangeView.first?.upperBound ?? 0
: 0

self.firstUncountedIndex = self.lineStartIndexes.integerLessThanOrEqualTo(firstInvalidIndex) ?? 0
}
}

0 comments on commit 06136f2

Please sign in to comment.