31304 - Autocomplete for enum values fails when typing "/" (#31362)

31304 - Autocomplete for enum values fails when typing "/"
This commit is contained in:
Daniel Rosenwasser 2019-05-24 16:17:25 -07:00 committed by GitHub
commit 38f3b05cb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View File

@ -49,7 +49,9 @@ namespace ts.Completions {
const compilerOptions = program.getCompilerOptions();
const contextToken = findPrecedingToken(position, sourceFile);
if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) return undefined;
if (triggerCharacter && !isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) {
return undefined;
}
const stringCompletions = StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences);
if (stringCompletions) {

View File

@ -0,0 +1,30 @@
/// <reference path="fourslash.ts" />
//// type A = "a/b" | "b/a";
//// const a: A = "a/*1*/";
////
//// type B = "a@b" | "b@a";
//// const a: B = "a@/*2*/";
////
//// type C = "a.b" | "b.a";
//// const c: C = "a./*3*/";
////
//// type D = "a'b" | "b'a";
//// const d: D = "a'/*4*/";
////
//// type E = "a`b" | "b`a";
//// const e: E = "a`/*5*/";
////
//// type F = 'a"b' | 'b"a';
//// const f: F = 'a"/*6*/';
////
//// type G = "a<b" | "b<a";
//// const g: G = 'a</*7*/';
verify.completions({ marker: '1', exact: ["a/b", "b/a"], triggerCharacter: "/" });
verify.completions({ marker: "2", exact: ["a@b", "b@a"], triggerCharacter: "@" });
verify.completions({ marker: "3", exact: ["a.b", "b.a"], triggerCharacter: "." });
verify.completions({ marker: "4", exact: ["a'b", "b'a"], triggerCharacter: "'" });
verify.completions({ marker: "5", exact: ["a`b", "b`a"], triggerCharacter: "`" });
verify.completions({ marker: "6", exact: ['a"b', 'b"a'], triggerCharacter: '"' });
verify.completions({ marker: "7", exact: ["a<b", "b<a"], triggerCharacter: '<' });