Skip to content

Commit 79b66ea

Browse files
committed
1 parent caf838e commit 79b66ea

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/vs/editor/common/model/indentationGuesser.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ function spacesDiff(a: string, aLength: number, b: string, bLength: number, resu
7272

7373
if (spacesDiff > 0 && 0 <= bSpacesCnt - 1 && bSpacesCnt - 1 < a.length && bSpacesCnt < b.length) {
7474
if (b.charCodeAt(bSpacesCnt) !== CharCode.Space && a.charCodeAt(bSpacesCnt - 1) === CharCode.Space) {
75-
// This looks like an alignment desire: e.g.
76-
// const a = b + c,
77-
// d = b - c;
78-
79-
result.looksLikeAlignment = true;
75+
if (a.charCodeAt(a.length - 1) === CharCode.Comma) {
76+
// This looks like an alignment desire: e.g.
77+
// const a = b + c,
78+
// d = b - c;
79+
result.looksLikeAlignment = true;
80+
}
8081
}
8182
}
8283
return;

src/vs/editor/test/common/model/textModel.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,18 @@ suite('Editor Model - TextModel', () => {
648648
]);
649649
});
650650

651+
test('issue #84217: Broken indentation detection', () => {
652+
assertGuess(true, 4, [
653+
'def main():',
654+
' print(\'hello\')',
655+
]);
656+
assertGuess(true, 4, [
657+
'def main():',
658+
' with open(\'foo\') as fp:',
659+
' print(fp.read())',
660+
]);
661+
});
662+
651663
test('validatePosition', () => {
652664

653665
let m = TextModel.createFromString('line one\nline two');

0 commit comments

Comments
 (0)