@@ -734,11 +734,12 @@ export interface Client {
734
734
getVcpkgEnabled ( ) : Thenable < boolean > ;
735
735
getCurrentCompilerPathAndArgs ( ) : Thenable < util . CompilerPathAndArgs | undefined > ;
736
736
getKnownCompilers ( ) : Thenable < configs . KnownCompiler [ ] | undefined > ;
737
- takeOwnership ( document : vscode . TextDocument ) : void ;
737
+ takeOwnership ( document : vscode . TextDocument ) : Promise < void > ;
738
+ sendDidOpen ( document : vscode . TextDocument ) : Promise < void > ;
738
739
queueTask < T > ( task : ( ) => Thenable < T > ) : Promise < T > ;
739
- requestWhenReady < T > ( request : ( ) => Thenable < T > ) : Thenable < T > ;
740
- notifyWhenLanguageClientReady ( notify : ( ) => void ) : void ;
741
- awaitUntilLanguageClientReady ( ) : Thenable < void > ;
740
+ requestWhenReady < T > ( request : ( ) => Thenable < T > ) : Promise < T > ;
741
+ notifyWhenLanguageClientReady < T > ( notify : ( ) => T ) : Promise < T > ;
742
+ awaitUntilLanguageClientReady ( ) : Promise < void > ;
742
743
requestSwitchHeaderSource ( rootUri : vscode . Uri , fileName : string ) : Thenable < string > ;
743
744
activeDocumentChanged ( document : vscode . TextDocument ) : Promise < void > ;
744
745
restartIntelliSenseForFile ( document : vscode . TextDocument ) : Promise < void > ;
@@ -1934,7 +1935,13 @@ export class DefaultClient implements Client {
1934
1935
* that it knows about the file, as well as adding it to this client's set of
1935
1936
* tracked documents.
1936
1937
*/
1937
- public takeOwnership ( document : vscode . TextDocument ) : void {
1938
+ public async takeOwnership ( document : vscode . TextDocument ) : Promise < void > {
1939
+ this . trackedDocuments . add ( document ) ;
1940
+ this . updateActiveDocumentTextOptions ( ) ;
1941
+ await this . requestWhenReady ( ( ) => this . sendDidOpen ( document ) ) ;
1942
+ }
1943
+
1944
+ public async sendDidOpen ( document : vscode . TextDocument ) : Promise < void > {
1938
1945
const params : DidOpenTextDocumentParams = {
1939
1946
textDocument : {
1940
1947
uri : document . uri . toString ( ) ,
@@ -1943,9 +1950,7 @@ export class DefaultClient implements Client {
1943
1950
text : document . getText ( )
1944
1951
}
1945
1952
} ;
1946
- this . updateActiveDocumentTextOptions ( ) ;
1947
- this . notifyWhenLanguageClientReady ( ( ) => this . languageClient . sendNotification ( DidOpenNotification , params ) ) ;
1948
- this . trackedDocuments . add ( document ) ;
1953
+ await this . languageClient . sendNotification ( DidOpenNotification , params ) ;
1949
1954
}
1950
1955
1951
1956
/**
@@ -2016,7 +2021,7 @@ export class DefaultClient implements Client {
2016
2021
} ) ;
2017
2022
}
2018
2023
2019
- public requestWhenReady < T > ( request : ( ) => Thenable < T > ) : Thenable < T > {
2024
+ public requestWhenReady < T > ( request : ( ) => Thenable < T > ) : Promise < T > {
2020
2025
return this . queueTask ( request ) ;
2021
2026
}
2022
2027
@@ -2027,7 +2032,7 @@ export class DefaultClient implements Client {
2027
2032
return this . queueTask ( task ) ;
2028
2033
}
2029
2034
2030
- public awaitUntilLanguageClientReady ( ) : Thenable < void > {
2035
+ public awaitUntilLanguageClientReady ( ) : Promise < void > {
2031
2036
const task : ( ) => Thenable < void > = ( ) => new Promise < void > ( resolve => {
2032
2037
resolve ( ) ;
2033
2038
} ) ;
@@ -2116,7 +2121,7 @@ export class DefaultClient implements Client {
2116
2121
if ( fileName === ".editorconfig" ) {
2117
2122
cachedEditorConfigSettings . clear ( ) ;
2118
2123
cachedEditorConfigLookups . clear ( ) ;
2119
- await this . updateActiveDocumentTextOptions ( ) ;
2124
+ this . updateActiveDocumentTextOptions ( ) ;
2120
2125
}
2121
2126
if ( fileName === ".clang-format" || fileName === "_clang-format" ) {
2122
2127
cachedEditorConfigLookups . clear ( ) ;
@@ -2144,7 +2149,7 @@ export class DefaultClient implements Client {
2144
2149
if ( fileName === ".editorconfig" ) {
2145
2150
cachedEditorConfigSettings . clear ( ) ;
2146
2151
cachedEditorConfigLookups . clear ( ) ;
2147
- await this . updateActiveDocumentTextOptions ( ) ;
2152
+ this . updateActiveDocumentTextOptions ( ) ;
2148
2153
}
2149
2154
if ( dotIndex !== - 1 ) {
2150
2155
const ext : string = uri . fsPath . substring ( dotIndex + 1 ) ;
@@ -2456,7 +2461,7 @@ export class DefaultClient implements Client {
2456
2461
return this . languageClient . sendRequest ( QueryCompilerDefaultsRequest , params ) ;
2457
2462
}
2458
2463
2459
- private async updateActiveDocumentTextOptions ( ) : Promise < void > {
2464
+ private updateActiveDocumentTextOptions ( ) : void {
2460
2465
const editor : vscode . TextEditor | undefined = vscode . window . activeTextEditor ;
2461
2466
if ( editor ?. document ?. uri . scheme === "file"
2462
2467
&& ( editor . document . languageId === "c"
@@ -2493,7 +2498,7 @@ export class DefaultClient implements Client {
2493
2498
* notifications to the language server
2494
2499
*/
2495
2500
public async activeDocumentChanged ( document : vscode . TextDocument ) : Promise < void > {
2496
- await this . updateActiveDocumentTextOptions ( ) ;
2501
+ this . updateActiveDocumentTextOptions ( ) ;
2497
2502
await this . awaitUntilLanguageClientReady ( ) ;
2498
2503
this . languageClient . sendNotification ( ActiveDocumentChangeNotification , this . languageClient . code2ProtocolConverter . asTextDocumentIdentifier ( document ) ) ;
2499
2504
}
@@ -3417,11 +3422,12 @@ class NullClient implements Client {
3417
3422
getVcpkgEnabled ( ) : Thenable < boolean > { return Promise . resolve ( false ) ; }
3418
3423
getCurrentCompilerPathAndArgs ( ) : Thenable < util . CompilerPathAndArgs | undefined > { return Promise . resolve ( undefined ) ; }
3419
3424
getKnownCompilers ( ) : Thenable < configs . KnownCompiler [ ] | undefined > { return Promise . resolve ( [ ] ) ; }
3420
- takeOwnership ( document : vscode . TextDocument ) : void { }
3425
+ takeOwnership ( document : vscode . TextDocument ) : Promise < void > { return Promise . resolve ( ) ; }
3426
+ sendDidOpen ( document : vscode . TextDocument ) : Promise < void > { return Promise . resolve ( ) ; }
3421
3427
queueTask < T > ( task : ( ) => Thenable < T > ) : Promise < T > { return Promise . resolve ( task ( ) ) ; }
3422
- requestWhenReady < T > ( request : ( ) => Thenable < T > ) : Thenable < T > { return request ( ) ; }
3423
- notifyWhenLanguageClientReady ( notify : ( ) => void ) : void { }
3424
- awaitUntilLanguageClientReady ( ) : Thenable < void > { return Promise . resolve ( ) ; }
3428
+ requestWhenReady < T > ( request : ( ) => Thenable < T > ) : Promise < T > { return Promise . resolve ( request ( ) ) ; }
3429
+ notifyWhenLanguageClientReady < T > ( notify : ( ) => T ) : Promise < T > { return Promise . resolve ( notify ( ) ) ; }
3430
+ awaitUntilLanguageClientReady ( ) : Promise < void > { return Promise . resolve ( ) ; }
3425
3431
requestSwitchHeaderSource ( rootUri : vscode . Uri , fileName : string ) : Thenable < string > { return Promise . resolve ( "" ) ; }
3426
3432
activeDocumentChanged ( document : vscode . TextDocument ) : Promise < void > { return Promise . resolve ( ) ; }
3427
3433
restartIntelliSenseForFile ( document : vscode . TextDocument ) : Promise < void > { return Promise . resolve ( ) ; }
0 commit comments