@@ -31,7 +31,6 @@ interface DotAccessorContext {
31
31
interface CompletionContext {
32
32
readonly isNewIdentifierLocation : boolean ;
33
33
readonly isMemberCompletion : boolean ;
34
- readonly isInValidCommitCharacterContext : boolean ;
35
34
36
35
readonly dotAccessorContext ?: DotAccessorContext ;
37
36
@@ -40,8 +39,6 @@ interface CompletionContext {
40
39
41
40
readonly wordRange : vscode . Range | undefined ;
42
41
readonly line : string ;
43
-
44
- readonly useFuzzyWordRangeLogic : boolean ;
45
42
}
46
43
47
44
type ResolvedCompletionItem = {
@@ -102,7 +99,7 @@ class MyCompletionItem extends vscode.CompletionItem {
102
99
if ( completionContext . isMemberCompletion && completionContext . dotAccessorContext && ! ( this . insertText instanceof vscode . SnippetString ) ) {
103
100
this . filterText = completionContext . dotAccessorContext . text + ( this . insertText || this . textLabel ) ;
104
101
if ( ! this . range ) {
105
- const replacementRange = this . getFuzzyWordRange ( ) ;
102
+ const replacementRange = this . completionContext . wordRange ;
106
103
if ( replacementRange ) {
107
104
this . range = {
108
105
inserting : completionContext . dotAccessorContext . range ,
@@ -423,7 +420,7 @@ class MyCompletionItem extends vscode.CompletionItem {
423
420
return ;
424
421
}
425
422
426
- const replaceRange = this . getFuzzyWordRange ( ) ;
423
+ const replaceRange = this . completionContext . wordRange ;
427
424
if ( replaceRange ) {
428
425
this . range = {
429
426
inserting : new vscode . Range ( replaceRange . start , this . position ) ,
@@ -432,23 +429,6 @@ class MyCompletionItem extends vscode.CompletionItem {
432
429
}
433
430
}
434
431
435
- private getFuzzyWordRange ( ) {
436
- if ( this . completionContext . useFuzzyWordRangeLogic ) {
437
- // Try getting longer, prefix based range for completions that span words
438
- const text = this . completionContext . line . slice ( Math . max ( 0 , this . position . character - this . textLabel . length ) , this . position . character ) . toLowerCase ( ) ;
439
- const entryName = this . textLabel . toLowerCase ( ) ;
440
- for ( let i = entryName . length ; i >= 0 ; -- i ) {
441
- if ( text . endsWith ( entryName . substr ( 0 , i ) ) && ( ! this . completionContext . wordRange || this . completionContext . wordRange . start . character > this . position . character - i ) ) {
442
- return new vscode . Range (
443
- new vscode . Position ( this . position . line , Math . max ( 0 , this . position . character - i ) ) ,
444
- this . position ) ;
445
- }
446
- }
447
- }
448
-
449
- return this . completionContext . wordRange ;
450
- }
451
-
452
432
private static convertKind ( kind : string ) : vscode . CompletionItemKind {
453
433
switch ( kind ) {
454
434
case PConst . Kind . primitiveType :
@@ -517,7 +497,7 @@ class MyCompletionItem extends vscode.CompletionItem {
517
497
return undefined ;
518
498
}
519
499
520
- if ( context . isNewIdentifierLocation || ! context . isInValidCommitCharacterContext ) {
500
+ if ( context . isNewIdentifierLocation ) {
521
501
return undefined ;
522
502
}
523
503
@@ -790,16 +770,14 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<
790
770
metadata = response . metadata ;
791
771
}
792
772
793
- const completionContext = {
773
+ const completionContext : CompletionContext = {
794
774
isNewIdentifierLocation,
795
775
isMemberCompletion,
796
776
dotAccessorContext,
797
- isInValidCommitCharacterContext : this . isInValidCommitCharacterContext ( document , position ) ,
798
777
enableCallCompletions : ! completionConfiguration . completeFunctionCalls ,
799
778
wordRange,
800
779
line : line . text ,
801
780
completeFunctionCalls : completionConfiguration . completeFunctionCalls ,
802
- useFuzzyWordRangeLogic : this . client . apiVersion . lt ( API . v390 ) ,
803
781
} ;
804
782
805
783
let includesPackageJsonImport = false ;
@@ -864,26 +842,27 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<
864
842
865
843
private getTsTriggerCharacter ( context : vscode . CompletionContext ) : Proto . CompletionsTriggerCharacter | undefined {
866
844
switch ( context . triggerCharacter ) {
867
- case '@' : // Workaround for https://github.com/microsoft/TypeScript/issues/27321
845
+ case '@' : { // Workaround for https://github.com/microsoft/TypeScript/issues/27321
868
846
return this . client . apiVersion . gte ( API . v310 ) && this . client . apiVersion . lt ( API . v320 ) ? undefined : '@' ;
869
-
870
- case '#' : // Workaround for https://github.com/microsoft/TypeScript/issues/36367
847
+ }
848
+ case '#' : { // Workaround for https://github.com/microsoft/TypeScript/issues/36367
871
849
return this . client . apiVersion . lt ( API . v381 ) ? undefined : '#' ;
872
-
850
+ }
873
851
case ' ' : {
874
- const space : Proto . CompletionsTriggerCharacter = ' ' ;
875
- return this . client . apiVersion . gte ( API . v430 ) ? space : undefined ;
852
+ return this . client . apiVersion . gte ( API . v430 ) ? ' ' : undefined ;
876
853
}
877
854
case '.' :
878
855
case '"' :
879
856
case '\'' :
880
857
case '`' :
881
858
case '/' :
882
- case '<' :
859
+ case '<' : {
883
860
return context . triggerCharacter ;
861
+ }
862
+ default : {
863
+ return undefined ;
864
+ }
884
865
}
885
-
886
- return undefined ;
887
866
}
888
867
889
868
public async resolveCompletionItem (
@@ -894,25 +873,6 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<
894
873
return item ;
895
874
}
896
875
897
- private isInValidCommitCharacterContext (
898
- document : vscode . TextDocument ,
899
- position : vscode . Position
900
- ) : boolean {
901
- if ( this . client . apiVersion . lt ( API . v320 ) ) {
902
- // Workaround for https://github.com/microsoft/TypeScript/issues/27742
903
- // Only enable dot completions when previous character not a dot preceded by whitespace.
904
- // Prevents incorrectly completing while typing spread operators.
905
- if ( position . character > 1 ) {
906
- const preText = document . getText ( new vscode . Range (
907
- position . line , 0 ,
908
- position . line , position . character ) ) ;
909
- return preText . match ( / ( \s | ^ ) \. $ / ig) === null ;
910
- }
911
- }
912
-
913
- return true ;
914
- }
915
-
916
876
private shouldTrigger (
917
877
context : vscode . CompletionContext ,
918
878
line : vscode . TextLine ,
0 commit comments