mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 03:20:56 -06:00
ignore trigger chars within a string literal
This commit is contained in:
parent
b7fe99a88c
commit
8965650bc3
@ -40,7 +40,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) {
|
||||
|
||||
@ -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: '<' });
|
||||
Loading…
x
Reference in New Issue
Block a user