File tree Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -4666,6 +4666,10 @@ function getCompletionData(
4666
4666
return undefined ;
4667
4667
}
4668
4668
4669
+ function isInDifferentLineThanContextToken ( contextToken : Node , position : number ) : boolean {
4670
+ return sourceFile . getLineEndOfPosition ( contextToken . getEnd ( ) ) < position ;
4671
+ }
4672
+
4669
4673
/**
4670
4674
* @returns true if we are certain that the currently edited location must define a new location; false otherwise.
4671
4675
*/
@@ -4733,15 +4737,24 @@ function getCompletionData(
4733
4737
case SyntaxKind . SetKeyword :
4734
4738
return ! isFromObjectTypeDeclaration ( contextToken ) ;
4735
4739
4736
- case SyntaxKind . Identifier :
4740
+ case SyntaxKind . Identifier : {
4737
4741
if ( containingNodeKind === SyntaxKind . ImportSpecifier &&
4738
4742
contextToken === ( parent as ImportSpecifier ) . name &&
4739
4743
( contextToken as Identifier ) . text === "type"
4740
4744
) {
4741
4745
// import { type | }
4742
4746
return false ;
4743
4747
}
4748
+ const ancestorVariableDeclaration = findAncestor (
4749
+ contextToken . parent , isVariableDeclaration ) ;
4750
+ if ( ancestorVariableDeclaration
4751
+ && isInDifferentLineThanContextToken ( contextToken , position ) ) {
4752
+ // let a
4753
+ // |
4754
+ return false ;
4755
+ }
4744
4756
break ;
4757
+ }
4745
4758
4746
4759
case SyntaxKind . ClassKeyword :
4747
4760
case SyntaxKind . EnumKeyword :
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts" />
2
+
3
+ // issue: https://github.com/microsoft/TypeScript/issues/54729
4
+ // Tests that `isCompletionListBlocker` returns true at position 1, and returns false after a newline.
5
+
6
+
7
+ ////let foo /*1*/
8
+ /////*2*/
9
+ /////*3*/
10
+
11
+ verify . completions (
12
+ { marker : "1" , exact : undefined } ,
13
+ {
14
+ marker : [ "2" , "3" ] ,
15
+ exact : completion . globalsPlus ( [
16
+ {
17
+ name : "foo" ,
18
+ } ,
19
+ ] ) ,
20
+ }
21
+ ) ;
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts" />
2
+
3
+ // issue: https://github.com/microsoft/TypeScript/issues/54729
4
+ // Tests that `isCompletionListBlocker` returns true at position 1, and returns false after a newline.
5
+
6
+ ////let foo = 5 as const /*1*/
7
+ /////*2*/
8
+
9
+ verify . completions (
10
+ { marker : "1" , exact : undefined } ,
11
+ {
12
+ marker : "2" ,
13
+ exact : completion . globalsPlus ( [
14
+ {
15
+ name : "foo" ,
16
+ } ,
17
+ ] ) ,
18
+ }
19
+ ) ;
You can’t perform that action at this time.
0 commit comments