Skip to content

Commit aa12ec4

Browse files
authored
Fix smart select on last blank line of file (microsoft#32544)
* Fix SmartSelection on last blank line of file * Add baseline
1 parent e8966ce commit aa12ec4

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/services/smartSelection.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ namespace ts.SmartSelectionRange {
6464
parentNode = node;
6565
break;
6666
}
67+
68+
// If we made it to the end of the for loop, we’re done.
69+
// In practice, I’ve only seen this happen at the very end
70+
// of a SourceFile.
71+
if (i === children.length - 1) {
72+
break outer;
73+
}
6774
}
6875
}
6976

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class C {}
2+
/**/
3+
4+
5+
class C {}↲
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference path="fourslash.ts" />
2+
////class C {}
3+
/////**/
4+
5+
verify.baselineSmartSelection();

0 commit comments

Comments
 (0)