@@ -798,8 +798,8 @@ namespace FourSlash {
798798 }
799799
800800 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 }
803803 : expected ;
804804
805805 if ( actual . insertText !== insertText ) {
@@ -825,6 +825,7 @@ namespace FourSlash {
825825 assert . equal ( actual . hasAction , hasAction ) ;
826826 assert . equal ( actual . isRecommended , isRecommended ) ;
827827 assert . equal ( actual . source , source ) ;
828+ assert . equal ( actual . sortText , sortText || ts . Completions . SortText . LocationPriority , this . messageAtLastKnownMarker ( `Actual entry: ${ JSON . stringify ( actual ) } ` ) ) ;
828829
829830 if ( text !== undefined ) {
830831 const actualDetails = this . getCompletionEntryDetails ( actual . name , actual . source ) ! ;
@@ -4434,18 +4435,63 @@ namespace FourSlashInterface {
44344435 }
44354436 }
44364437 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+ } ) ;
44454487
44464488 const res : ExpectedCompletionEntryObject [ ] = [ ] ;
44474489 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+ } ) ;
44494495 }
44504496 export const keywordsWithUndefined : ReadonlyArray < ExpectedCompletionEntryObject > = res ;
44514497 export const keywords : ReadonlyArray < ExpectedCompletionEntryObject > = keywordsWithUndefined . filter ( k => k . name !== "undefined" ) ;
@@ -4552,11 +4598,15 @@ namespace FourSlashInterface {
45524598 moduleEntry ( "Intl" ) ,
45534599 ] ;
45544600
4601+ export const globalThisEntry : ExpectedCompletionEntry = {
4602+ name : "globalThis" ,
4603+ kind : "module" ,
4604+ sortText : SortText . GlobalsOrKeywords
4605+ } ;
45554606 export const globalTypes = globalTypesPlus ( [ ] ) ;
4556-
45574607 export function globalTypesPlus ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > {
45584608 return [
4559- { name : "globalThis" , kind : "module" } ,
4609+ globalThisEntry ,
45604610 ...globalTypeDecls ,
45614611 ...plus ,
45624612 ...typeKeywords ,
@@ -4605,7 +4655,11 @@ namespace FourSlashInterface {
46054655 export const classElementInJsKeywords = getInJsKeywords ( classElementKeywords ) ;
46064656
46074657 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+ } ) ) ;
46094663
46104664 export const functionMembers : ReadonlyArray < ExpectedCompletionEntryObject > = [
46114665 methodEntry ( "apply" ) ,
@@ -4834,13 +4888,18 @@ namespace FourSlashInterface {
48344888 "await" ,
48354889 ] . map ( keywordEntry ) ;
48364890
4891+ export const undefinedVarEntry : ExpectedCompletionEntry = {
4892+ name : "undefined" ,
4893+ kind : "var" ,
4894+ sortText : SortText . GlobalsOrKeywords
4895+ } ;
48374896 // TODO: many of these are inappropriate to always provide
48384897 export const globalsInsideFunction = ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > => [
48394898 { name : "arguments" , kind : "local var" } ,
48404899 ...plus ,
4841- { name : "globalThis" , kind : "module" } ,
4900+ globalThisEntry ,
48424901 ...globalsVars ,
4843- { name : "undefined" , kind : "var" } ,
4902+ undefinedVarEntry ,
48444903 ...globalKeywordsInsideFunction ,
48454904 ] ;
48464905
@@ -4849,10 +4908,10 @@ namespace FourSlashInterface {
48494908 // TODO: many of these are inappropriate to always provide
48504909 export const globalsInJsInsideFunction = ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > => [
48514910 { name : "arguments" , kind : "local var" } ,
4852- { name : "globalThis" , kind : "module" } ,
4911+ globalThisEntry ,
48534912 ...globalsVars ,
48544913 ...plus ,
4855- { name : "undefined" , kind : "var" } ,
4914+ undefinedVarEntry ,
48564915 ...globalInJsKeywordsInsideFunction ,
48574916 ] ;
48584917
@@ -4990,34 +5049,34 @@ namespace FourSlashInterface {
49905049 } ) ( ) ;
49915050
49925051 export const globals : ReadonlyArray < ExpectedCompletionEntryObject > = [
4993- { name : "globalThis" , kind : "module" } ,
5052+ globalThisEntry ,
49945053 ...globalsVars ,
4995- { name : "undefined" , kind : "var" } ,
5054+ undefinedVarEntry ,
49965055 ...globalKeywords
49975056 ] ;
49985057
49995058 export const globalsInJs : ReadonlyArray < ExpectedCompletionEntryObject > = [
5000- { name : "globalThis" , kind : "module" } ,
5059+ globalThisEntry ,
50015060 ...globalsVars ,
5002- { name : "undefined" , kind : "var" } ,
5061+ undefinedVarEntry ,
50035062 ...globalInJsKeywords
50045063 ] ;
50055064
50065065 export function globalsPlus ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > {
50075066 return [
5008- { name : "globalThis" , kind : "module" } ,
5067+ globalThisEntry ,
50095068 ...globalsVars ,
50105069 ...plus ,
5011- { name : "undefined" , kind : "var" } ,
5070+ undefinedVarEntry ,
50125071 ...globalKeywords ] ;
50135072 }
50145073
50155074 export function globalsInJsPlus ( plus : ReadonlyArray < ExpectedCompletionEntry > ) : ReadonlyArray < ExpectedCompletionEntry > {
50165075 return [
5017- { name : "globalThis" , kind : "module" } ,
5076+ globalThisEntry ,
50185077 ...globalsVars ,
50195078 ...plus ,
5020- { name : "undefined" , kind : "var" } ,
5079+ undefinedVarEntry ,
50215080 ...globalInJsKeywords ] ;
50225081 }
50235082 }
@@ -5050,6 +5109,7 @@ namespace FourSlashInterface {
50505109 readonly documentation ?: string ;
50515110 readonly sourceDisplay ?: string ;
50525111 readonly tags ?: ReadonlyArray < ts . JSDocTagInfo > ;
5112+ readonly sortText ?: ts . Completions . SortText ;
50535113 }
50545114
50555115 export interface VerifyCompletionsOptions {
0 commit comments