Skip to content

Commit 6b13a60

Browse files
committed
Fix space hiding
1 parent 1c9384e commit 6b13a60

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Core/Sources/SuggestionWidget/SyntaxHighlighting.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func convertToCodeLines(
133133
) -> (code: [NSAttributedString], commonLeadingSpaceCount: Int) {
134134
let input = formattedCode.string
135135
func isEmptyLine(_ line: String) -> Bool {
136+
if line.isEmpty { return true }
136137
guard let regex = try? NSRegularExpression(pattern: #"^\s*\n?$"#) else { return false }
137138
if regex.firstMatch(
138139
in: line,
@@ -149,12 +150,11 @@ func convertToCodeLines(
149150
if !droppingLeadingSpaces { return 0 }
150151
let splitted = separatedInput
151152
var result = 0
152-
outerLoop: for i in [4, 8, 12, 16, 20] {
153+
outerLoop: for i in [4, 8, 12, 16, 20, 24] {
153154
for line in splitted {
154155
if isEmptyLine(line) { continue }
155156
if i >= line.count { break outerLoop }
156-
let targetIndex = line.index(line.startIndex, offsetBy: i - 1)
157-
if line[targetIndex] != " " { break outerLoop }
157+
if !line.hasPrefix(.init(repeating: " ", count: i)) { break outerLoop }
158158
}
159159
result = i
160160
}

0 commit comments

Comments
 (0)