Skip to content

Commit c095bb3

Browse files
committed
[format on keystroke]added comment to the verification of preceding token
1 parent 889264f commit c095bb3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/services/formatting/formatting.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ module ts.formatting {
120120

121121
function findOutermostParent(position: number, expectedTokenKind: SyntaxKind, sourceFile: SourceFile): Node {
122122
var precedingToken = findPrecedingToken(position, sourceFile);
123+
124+
// when it is claimed that trigger character was typed at given position
125+
// we verify that there is a token with a matching kind whose end is equal to position (because the character was just typed).
126+
// If this condition is not hold - then trigger character was typed in some other context,
127+
// i.e.in comment and thus should not trigger autoformatting
123128
if (!precedingToken ||
124129
precedingToken.kind !== expectedTokenKind ||
125130
position !== precedingToken.getEnd()) {

0 commit comments

Comments
 (0)