mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 20:44:53 -05:00
Skip invalid completion check immediately after newline (#55061)
Co-authored-by: Isabel Duan <isabelduan@microsoft.com>
This commit is contained in:
@@ -4666,6 +4666,10 @@ function getCompletionData(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isInDifferentLineThanContextToken(contextToken: Node, position: number): boolean {
|
||||
return sourceFile.getLineEndOfPosition(contextToken.getEnd()) < position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns true if we are certain that the currently edited location must define a new location; false otherwise.
|
||||
*/
|
||||
@@ -4733,7 +4737,7 @@ function getCompletionData(
|
||||
case SyntaxKind.SetKeyword:
|
||||
return !isFromObjectTypeDeclaration(contextToken);
|
||||
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.Identifier: {
|
||||
if (containingNodeKind === SyntaxKind.ImportSpecifier &&
|
||||
contextToken === (parent as ImportSpecifier).name &&
|
||||
(contextToken as Identifier).text === "type"
|
||||
@@ -4741,7 +4745,16 @@ function getCompletionData(
|
||||
// import { type | }
|
||||
return false;
|
||||
}
|
||||
const ancestorVariableDeclaration = findAncestor(
|
||||
contextToken.parent, isVariableDeclaration);
|
||||
if (ancestorVariableDeclaration
|
||||
&& isInDifferentLineThanContextToken(contextToken, position)) {
|
||||
// let a
|
||||
// |
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SyntaxKind.ClassKeyword:
|
||||
case SyntaxKind.EnumKeyword:
|
||||
|
||||
Reference in New Issue
Block a user