From 962c4de875640f0dd0716687f12b0aa59fbbbabb Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 27 Oct 2014 15:30:38 -0700 Subject: [PATCH] Address code review comments --- src/services/services.ts | 9 ++++----- .../cases/fourslash/completionListAfterFunction2.ts | 13 +++++++++++++ .../cases/fourslash/completionListAfterFunction3.ts | 12 ++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 tests/cases/fourslash/completionListAfterFunction2.ts create mode 100644 tests/cases/fourslash/completionListAfterFunction3.ts diff --git a/src/services/services.ts b/src/services/services.ts index 3584e016227..9270a3115dc 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2021,7 +2021,7 @@ module ts { var text = sourceFile.text; var width = comment.end - comment.pos; // is single line comment or just /* - if (width <=2 || text.charCodeAt(comment.pos + 1) === CharacterCodes.slash) { + if (width <= 2 || text.charCodeAt(comment.pos + 1) === CharacterCodes.slash) { return true; } else { @@ -2484,9 +2484,6 @@ module ts { } function isInStringOrRegularExpressionLiteral(previousToken: Node): boolean { - //var token = getTouchingPropertyName(sourceFile, position); - - // || token.kind === SyntaxKind.RegularExpressionLiteral if (previousToken.kind === SyntaxKind.StringLiteral) { // The position has to be either: 1. entirely within the token text, or // 2. at the end position, and the string literal is not terminated @@ -2498,7 +2495,9 @@ module ts { else if (position === end) { var width = end - start; var text = previousToken.getSourceFile().text; - return width <= 1 || text.charCodeAt(start) !== text.charCodeAt(end - 1); + return width <= 1 || + text.charCodeAt(start) !== text.charCodeAt(end - 1) || + text.charCodeAt(end - 2) === CharacterCodes.backslash; } } else if (previousToken.kind === SyntaxKind.RegularExpressionLiteral) { diff --git a/tests/cases/fourslash/completionListAfterFunction2.ts b/tests/cases/fourslash/completionListAfterFunction2.ts new file mode 100644 index 00000000000..c123e084972 --- /dev/null +++ b/tests/cases/fourslash/completionListAfterFunction2.ts @@ -0,0 +1,13 @@ +/// + +////// Outside the function expression +////declare var f1: (a: number) => void; /*1*/ +//// +////declare var f1: (b: number, b2: /*2*/) => void; + +goTo.marker("1"); +verify.not.completionListContains("a"); + +goTo.marker("2"); +verify.completionListContains("b"); + diff --git a/tests/cases/fourslash/completionListAfterFunction3.ts b/tests/cases/fourslash/completionListAfterFunction3.ts new file mode 100644 index 00000000000..575351ea648 --- /dev/null +++ b/tests/cases/fourslash/completionListAfterFunction3.ts @@ -0,0 +1,12 @@ +/// + +////// Outside the function expression +////var x1 = (a: number) => { }/*1*/; +//// +////var x2 = (b: number) => {/*2*/ }; + +goTo.marker("1"); +verify.not.completionListContains("a"); + +goTo.marker("2"); +verify.completionListContains("b");