Support '/' as a trigger character in path completions (#24042)

This commit is contained in:
Andy 2018-05-10 16:50:26 -07:00 committed by GitHub
parent 6ae4d3a516
commit 2be6aaf813
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -2218,7 +2218,9 @@ namespace ts.Completions {
// Opening JSX tag
return contextToken.kind === SyntaxKind.LessThanToken && contextToken.parent.kind !== SyntaxKind.BinaryExpression;
case "/":
return isJsxClosingElement(contextToken.parent);
return isStringLiteralLike(contextToken)
? !!tryGetImportFromModuleSpecifier(contextToken)
: contextToken.kind === SyntaxKind.SlashToken && isJsxClosingElement(contextToken.parent);
default:
return Debug.assertNever(triggerCharacter);
}

View file

@ -9,6 +9,9 @@
////// "/*quoteInComment*/ </*lessInComment*/
// @Filename: /foo/importMe.ts
////whatever
// @Filename: /a.tsx
////declare namespace JSX {
//// interface Element {}
@ -16,9 +19,10 @@
//// div: {};
//// }
////}
////const ctr = </*openTag*/
////const less = 1 </*lessThan*/
////const closeTag = <div> foo <//*closeTag*/
////const ctr = </*openTag*/;
////const less = 1 </*lessThan*/;
////const closeTag = <div> foo <//*closeTag*/;
////import something from "./foo//*path*/";
////const divide = 1 //*divide*/
verify.completions(
@ -37,5 +41,6 @@ verify.completions(
{ marker: "openTag", includes: "div", triggerCharacter: "<" },
{ marker: "lessThan", exact: undefined, triggerCharacter: "<" },
{ marker: "closeTag", exact: "div", triggerCharacter: "/" },
{ marker: "path", exact: "importMe", triggerCharacter: "/", isNewIdentifierLocation: true },
{ marker: "divide", exact: undefined, triggerCharacter: "/" },
);