@@ -798,8 +798,8 @@ namespace FourSlash {
798
798
}
799
799
800
800
private verifyCompletionEntry ( actual : ts . CompletionEntry , expected : FourSlashInterface . ExpectedCompletionEntry ) {
801
- const { insertText, replacementSpan, hasAction, isRecommended, kind, kindModifiers, text, documentation, tags, source, sourceDisplay } = typeof expected === "string"
802
- ? { insertText : undefined , replacementSpan : undefined , hasAction : undefined , isRecommended : undefined , kind : undefined , kindModifiers : undefined , text : undefined , documentation : undefined , tags : undefined , source : undefined , sourceDisplay : undefined }
801
+ const { insertText, replacementSpan, hasAction, isRecommended, kind, kindModifiers, text, documentation, tags, source, sourceDisplay, sortText } = typeof expected === "string"
802
+ ? { insertText : undefined , replacementSpan : undefined , hasAction : undefined , isRecommended : undefined , kind : undefined , kindModifiers : undefined , text : undefined , documentation : undefined , tags : undefined , source : undefined , sourceDisplay : undefined , sortText : undefined }
803
803
: expected ;
804
804
805
805
if ( actual . insertText !== insertText ) {
@@ -825,6 +825,7 @@ namespace FourSlash {
825
825
assert . equal ( actual . hasAction , hasAction ) ;
826
826
assert . equal ( actual . isRecommended , isRecommended ) ;
827
827
assert . equal ( actual . source , source ) ;
828
+ assert . equal ( actual . sortText , sortText || ts . Completions . SortText . LocationPriority , this . messageAtLastKnownMarker ( `Actual entry: ${ JSON . stringify ( actual ) } ` ) ) ;
828
829
829
830
if ( text !== undefined ) {
830
831
const actualDetails = this . getCompletionEntryDetails ( actual . name , actual . source ) ! ;
@@ -4434,18 +4435,63 @@ namespace FourSlashInterface {
4434
4435
}
4435
4436
}
4436
4437
export namespace Completion {
4437
- const functionEntry = ( name : string ) : ExpectedCompletionEntryObject => ( { name, kind : "function" , kindModifiers : "declare" } ) ;
4438
- const varEntry = ( name : string ) : ExpectedCompletionEntryObject => ( { name, kind : "var" , kindModifiers : "declare" } ) ;
4439
- const moduleEntry = ( name : string ) : ExpectedCompletionEntryObject => ( { name, kind : "module" , kindModifiers : "declare" } ) ;
4440
- const keywordEntry = ( name : string ) : ExpectedCompletionEntryObject => ( { name, kind : "keyword" } ) ;
4441
- const methodEntry = ( name : string ) : ExpectedCompletionEntryObject => ( { name, kind : "method" , kindModifiers : "declare" } ) ;
4442
- const propertyEntry = ( name : string ) : ExpectedCompletionEntryObject => ( { name, kind : "property" , kindModifiers : "declare" } ) ;
4443
- const interfaceEntry = ( name : string ) : ExpectedCompletionEntryObject => ( { name, kind : "interface" , kindModifiers : "declare" } ) ;
4444
- const typeEntry = ( name : string ) : ExpectedCompletionEntryObject => ( { name, kind : "type" , kindModifiers : "declare" } ) ;
4438
+ export import SortText = ts . Completions . SortText ;
4439
+
4440
+ const functionEntry = ( name : string ) : ExpectedCompletionEntryObject => ( {
4441
+ name,
4442
+ kind : "function" ,
4443
+ kindModifiers : "declare" ,
4444
+ sortText : SortText . GlobalsOrKeywords
4445
+ } ) ;
4446
+ const varEntry = ( name : string ) : ExpectedCompletionEntryObject => ( {
4447
+ name,
4448
+ kind : "var" ,
4449
+ kindModifiers : "declare" ,
4450
+ sortText : SortText . GlobalsOrKeywords
4451
+ } ) ;
4452
+ const moduleEntry = ( name : string ) : ExpectedCompletionEntryObject => ( {
4453
+ name,
4454
+ kind : "module" ,
4455
+ kindModifiers : "declare" ,
4456
+ sortText : SortText . GlobalsOrKeywords
4457
+ } ) ;
4458
+ const keywordEntry = ( name : string ) : ExpectedCompletionEntryObject => ( {
4459
+ name,
4460
+ kind : "keyword" ,
4461
+ sortText : SortText . GlobalsOrKeywords
4462
+ } ) ;
4463
+ const methodEntry = ( name : string ) : ExpectedCompletionEntryObject => ( {
4464
+ name,
4465
+ kind : "method" ,
4466
+ kindModifiers : "declare" ,
4467
+ sortText : SortText . LocationPriority
4468
+ } ) ;
4469
+ const propertyEntry = ( name : string ) : ExpectedCompletionEntryObject => ( {
4470
+ name,
4471
+ kind : "property" ,
4472
+ kindModifiers : "declare" ,
4473
+ sortText : SortText . LocationPriority
4474
+ } ) ;
4475
+ const interfaceEntry = ( name : string ) : ExpectedCompletionEntryObject => ( {
4476
+ name,
4477
+ kind : "interface" ,
4478
+ kindModifiers : "declare" ,
4479
+ sortText : SortText . GlobalsOrKeywords
4480
+ } ) ;
4481
+ const typeEntry = ( name : string ) : ExpectedCompletionEntryObject => ( {
4482
+ name,
4483
+ kind : "type" ,
4484
+ kindModifiers : "declare" ,
4485
+ sortText : SortText . GlobalsOrKeywords
4486
+ } ) ;
4445
4487
4446
4488
const res : ExpectedCompletionEntryObject [ ] = [ ] ;
4447
4489
for ( let i = ts . SyntaxKind . FirstKeyword ; i <= ts . SyntaxKind . LastKeyword ; i ++ ) {
4448
- res . push ( { name : ts . Debug . assertDefined ( ts . tokenToString ( i ) ) , kind : "keyword" } ) ;
4490
+ res . push ( {
4491
+ name : ts . Debug . assertDefined ( ts . tokenToString ( i ) ) ,
4492
+ kind : "keyword" ,
4493
+ sortText : SortText . GlobalsOrKeywords
4494
+ } ) ;
4449
4495
}
4450
4496
export const keywordsWithUndefined : ReadonlyArray < ExpectedCompletionEntryObject > = res ;
4451
4497
export const keywords : ReadonlyArray < ExpectedCompletionEntryObject > = keywordsWithUndefined . filter ( k => k . name !== "undefined" ) ;
@@ -4552,11 +4598,15 @@ namespace FourSlashInterface {
4552
4598
moduleEntry ( "Intl" ) ,
4553
4599
] ;
4554
4600
4601
+ export const globalThisEntry : ExpectedCompletionEntry = {
4602
+ name : "globalThis" ,
4603
+ kind : "module" ,
4604
+ sortText : SortText . GlobalsOrKeywords
4605
+ } ;
4555
4606
export const globalTypes = globalTypesPlus ( [ ] ) ;
4556
-
4557
4607
export function globalTypesPlus ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > {
4558
4608
return [
4559
- { name : "globalThis" , kind : "module" } ,
4609
+ globalThisEntry ,
4560
4610
...globalTypeDecls ,
4561
4611
...plus ,
4562
4612
...typeKeywords ,
@@ -4605,7 +4655,11 @@ namespace FourSlashInterface {
4605
4655
export const classElementInJsKeywords = getInJsKeywords ( classElementKeywords ) ;
4606
4656
4607
4657
export const constructorParameterKeywords : ReadonlyArray < ExpectedCompletionEntryObject > =
4608
- [ "private" , "protected" , "public" , "readonly" ] . map ( ( name ) : ExpectedCompletionEntryObject => ( { name, kind : "keyword" } ) ) ;
4658
+ [ "private" , "protected" , "public" , "readonly" ] . map ( ( name ) : ExpectedCompletionEntryObject => ( {
4659
+ name,
4660
+ kind : "keyword" ,
4661
+ sortText : SortText . GlobalsOrKeywords
4662
+ } ) ) ;
4609
4663
4610
4664
export const functionMembers : ReadonlyArray < ExpectedCompletionEntryObject > = [
4611
4665
methodEntry ( "apply" ) ,
@@ -4834,13 +4888,18 @@ namespace FourSlashInterface {
4834
4888
"await" ,
4835
4889
] . map ( keywordEntry ) ;
4836
4890
4891
+ export const undefinedVarEntry : ExpectedCompletionEntry = {
4892
+ name : "undefined" ,
4893
+ kind : "var" ,
4894
+ sortText : SortText . GlobalsOrKeywords
4895
+ } ;
4837
4896
// TODO: many of these are inappropriate to always provide
4838
4897
export const globalsInsideFunction = ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > => [
4839
4898
{ name : "arguments" , kind : "local var" } ,
4840
4899
...plus ,
4841
- { name : "globalThis" , kind : "module" } ,
4900
+ globalThisEntry ,
4842
4901
...globalsVars ,
4843
- { name : "undefined" , kind : "var" } ,
4902
+ undefinedVarEntry ,
4844
4903
...globalKeywordsInsideFunction ,
4845
4904
] ;
4846
4905
@@ -4849,10 +4908,10 @@ namespace FourSlashInterface {
4849
4908
// TODO: many of these are inappropriate to always provide
4850
4909
export const globalsInJsInsideFunction = ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > => [
4851
4910
{ name : "arguments" , kind : "local var" } ,
4852
- { name : "globalThis" , kind : "module" } ,
4911
+ globalThisEntry ,
4853
4912
...globalsVars ,
4854
4913
...plus ,
4855
- { name : "undefined" , kind : "var" } ,
4914
+ undefinedVarEntry ,
4856
4915
...globalInJsKeywordsInsideFunction ,
4857
4916
] ;
4858
4917
@@ -4990,34 +5049,34 @@ namespace FourSlashInterface {
4990
5049
} ) ( ) ;
4991
5050
4992
5051
export const globals : ReadonlyArray < ExpectedCompletionEntryObject > = [
4993
- { name : "globalThis" , kind : "module" } ,
5052
+ globalThisEntry ,
4994
5053
...globalsVars ,
4995
- { name : "undefined" , kind : "var" } ,
5054
+ undefinedVarEntry ,
4996
5055
...globalKeywords
4997
5056
] ;
4998
5057
4999
5058
export const globalsInJs : ReadonlyArray < ExpectedCompletionEntryObject > = [
5000
- { name : "globalThis" , kind : "module" } ,
5059
+ globalThisEntry ,
5001
5060
...globalsVars ,
5002
- { name : "undefined" , kind : "var" } ,
5061
+ undefinedVarEntry ,
5003
5062
...globalInJsKeywords
5004
5063
] ;
5005
5064
5006
5065
export function globalsPlus ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > {
5007
5066
return [
5008
- { name : "globalThis" , kind : "module" } ,
5067
+ globalThisEntry ,
5009
5068
...globalsVars ,
5010
5069
...plus ,
5011
- { name : "undefined" , kind : "var" } ,
5070
+ undefinedVarEntry ,
5012
5071
...globalKeywords ] ;
5013
5072
}
5014
5073
5015
5074
export function globalsInJsPlus ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > {
5016
5075
return [
5017
- { name : "globalThis" , kind : "module" } ,
5076
+ globalThisEntry ,
5018
5077
...globalsVars ,
5019
5078
...plus ,
5020
- { name : "undefined" , kind : "var" } ,
5079
+ undefinedVarEntry ,
5021
5080
...globalInJsKeywords ] ;
5022
5081
}
5023
5082
}
@@ -5050,6 +5109,7 @@ namespace FourSlashInterface {
5050
5109
readonly documentation ?: string ;
5051
5110
readonly sourceDisplay ?: string ;
5052
5111
readonly tags ?: ReadonlyArray < ts . JSDocTagInfo > ;
5112
+ readonly sortText ?: ts . Completions . SortText ;
5053
5113
}
5054
5114
5055
5115
export interface VerifyCompletionsOptions {
0 commit comments