ensure that autoformat is triggered by token characters

This commit is contained in:
Vladimir Matveev 2015-02-02 22:21:41 -08:00
parent bbbec22917
commit 889264f457
2 changed files with 16 additions and 1 deletions

View file

@ -120,7 +120,9 @@ module ts.formatting {
function findOutermostParent(position: number, expectedTokenKind: SyntaxKind, sourceFile: SourceFile): Node {
var precedingToken = findPrecedingToken(position, sourceFile);
if (!precedingToken || precedingToken.kind !== expectedTokenKind) {
if (!precedingToken ||
precedingToken.kind !== expectedTokenKind ||
position !== precedingToken.getEnd()) {
return undefined;
}

View file

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts'/>
////class A {
////foo( ); // /*1*/
////}
////function foo() { var x; } // /*2*/
goTo.marker("1");
edit.insert(";");
verify.currentLineContentIs("foo( ); // ;")
goTo.marker("2");
edit.insert("}");
verify.currentLineContentIs("function foo() { var x; } // }");