Skip to content

Commit

Permalink
Fix LineEndingScanner
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Aug 30, 2024
1 parent 32bbb35 commit 09e1c45
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CotEditor/Sources/LineEndingScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import ValueRange

@Observable final class LineEndingScanner: LineRangeCalculating {

var baseLineEnding: LineEnding
var baseLineEnding: LineEnding { didSet { self.invalidateLineEnding() } }

private(set) var lineEndings: [ValueRange<LineEnding>]
private(set) var inconsistentLineEndings: [ValueRange<LineEnding>]
Expand Down Expand Up @@ -100,4 +100,11 @@ import ValueRange
self.lineEndings.replace(items: insertedLineEndings, in: scanRange, changeInLength: delta)
self.inconsistentLineEndings.replace(items: inconsistentLineEndings, in: scanRange, changeInLength: delta)
}


/// Updates `inconsistentLineEndings` with the current base line ending.
private func invalidateLineEnding() {

self.inconsistentLineEndings = self.lineEndings.filter { $0.value != self.baseLineEnding }
}
}

0 comments on commit 09e1c45

Please sign in to comment.