diff --git a/src/services/completions.ts b/src/services/completions.ts
index 1b13943258b98..e9fc8c310ddee 100644
--- a/src/services/completions.ts
+++ b/src/services/completions.ts
@@ -4657,6 +4657,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.
*/
@@ -4724,7 +4728,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"
@@ -4732,7 +4736,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:
diff --git a/tests/cases/fourslash/completionAfterNewline.ts b/tests/cases/fourslash/completionAfterNewline.ts
new file mode 100644
index 0000000000000..94637a9fd9b41
--- /dev/null
+++ b/tests/cases/fourslash/completionAfterNewline.ts
@@ -0,0 +1,21 @@
+///
+
+// issue: https://github.com/microsoft/TypeScript/issues/54729
+// Tests that `isCompletionListBlocker` returns true at position 1, and returns false after a newline.
+
+
+////let foo /*1*/
+/////*2*/
+/////*3*/
+
+verify.completions(
+ { marker: "1", exact: undefined },
+ {
+ marker: ["2", "3"],
+ exact: completion.globalsPlus([
+ {
+ name: "foo",
+ },
+ ]),
+ }
+);
diff --git a/tests/cases/fourslash/completionAfterNewline2.ts b/tests/cases/fourslash/completionAfterNewline2.ts
new file mode 100644
index 0000000000000..495800ce17875
--- /dev/null
+++ b/tests/cases/fourslash/completionAfterNewline2.ts
@@ -0,0 +1,19 @@
+///
+
+// issue: https://github.com/microsoft/TypeScript/issues/54729
+// Tests that `isCompletionListBlocker` returns true at position 1, and returns false after a newline.
+
+////let foo = 5 as const /*1*/
+/////*2*/
+
+verify.completions(
+ { marker: "1", exact: undefined },
+ {
+ marker: "2",
+ exact: completion.globalsPlus([
+ {
+ name: "foo",
+ },
+ ]),
+ }
+);