Skip to content

Commit acc0276

Browse files
committed
Explicitly handle edge case
1 parent 3c801f3 commit acc0276

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/SwiftFormatEditProvider.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ export class SwiftFormatEditProvider
133133
formatting: vscode.FormattingOptions,
134134
) {
135135
// If a new line was entered, format the previous line
136-
if (ch === "\n" && position.line > 0) {
136+
if (ch === "\n") {
137+
if (position.line <= 0) {
138+
return [];
139+
}
137140
const previousLine = position.line - 1;
138141

139142
// If the previous line is empty, formatting is not required

0 commit comments

Comments
 (0)