Only show the opening tag name when completing a close tag

Fixes #5096
This commit is contained in:
Ryan Cavanaugh
2015-10-08 15:32:36 -07:00
parent 1e708b46a7
commit 24334b506c
2 changed files with 31 additions and 3 deletions

View File

@@ -3105,6 +3105,7 @@ namespace ts {
let node = currentToken;
let isRightOfDot = false;
let isRightOfOpenTag = false;
let isStartingCloseTag = false;
let location = getTouchingPropertyName(sourceFile, position);
if (contextToken) {
@@ -3130,9 +3131,14 @@ namespace ts {
return undefined;
}
}
else if (kind === SyntaxKind.LessThanToken && sourceFile.languageVariant === LanguageVariant.JSX) {
isRightOfOpenTag = true;
location = contextToken;
else if (sourceFile.languageVariant === LanguageVariant.JSX) {
if (kind === SyntaxKind.LessThanToken) {
isRightOfOpenTag = true;
location = contextToken;
}
else if (kind === SyntaxKind.SlashToken && contextToken.parent.kind === SyntaxKind.JsxClosingElement) {
isStartingCloseTag = true;
}
}
}
@@ -3155,6 +3161,13 @@ namespace ts {
isMemberCompletion = true;
isNewIdentifierLocation = false;
}
else if (isStartingCloseTag) {
let tagName = (<JsxElement>contextToken.parent.parent).openingElement.tagName;
symbols = [typeChecker.getSymbolAtLocation(tagName)];
isMemberCompletion = true;
isNewIdentifierLocation = false;
}
else {
// For JavaScript or TypeScript, if we're not after a dot, then just try to get the
// global symbols in scope. These results should be valid for either language as

View File

@@ -0,0 +1,15 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: { ONE: string; TWO: number; }
//// }
//// }
//// var x1 = <div><//**/
goTo.marker();
verify.completionListItemsCountIsGreaterThan(0);
verify.not.completionListItemsCountIsGreaterThan(1);
verify.completionListContains('div');