Skip to content

Commit a1e048c

Browse files
committed
Use ClosedRange instead of Array<Int>
1 parent 57228f4 commit a1e048c

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Sources/CodeEditSourceEditor/Controller/TextViewController+IndentLines.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import CodeEditTextView
99
import AppKit
1010

1111
extension TextViewController {
12-
/// Handles indentation and unindentation
12+
/// Handles indentation and unindentation
1313
///
1414
/// Handles the indentation of lines in the text view based on the current indentation option.
1515
///
@@ -53,22 +53,17 @@ for cursorPosition in self.cursorPositions.reversed() {
5353
return false
5454
}
5555

56-
private func getHighlightedLines(for range: NSRange) -> [Int]? {
56+
private func getHighlightedLines(for range: NSRange) -> ClosedRange<Int>? {
5757
guard let startLineInfo = textView.layoutManager.textLineForOffset(range.lowerBound) else {
5858
return nil
5959
}
60-
var lines: [Int] = [startLineInfo.index]
6160

6261
guard let endLineInfo = textView.layoutManager.textLineForOffset(range.upperBound),
6362
endLineInfo.index != startLineInfo.index else {
64-
return lines
65-
}
66-
if endLineInfo.index == startLineInfo.index + 1 {
67-
lines.append(endLineInfo.index)
68-
return lines
63+
return startLineInfo.index...startLineInfo.index
6964
}
7065

71-
return Array(startLineInfo.index...endLineInfo.index)
66+
return startLineInfo.index...endLineInfo.index
7267
}
7368

7469
private func adjustIndentation(lineIndex: Int, indentationChars: String, inwards: Bool) {

0 commit comments

Comments
 (0)