@@ -235,6 +235,7 @@ const IntervalTimerNotification: NotificationType<void, void> = new Notification
235235const CustomConfigurationNotification : NotificationType < CustomConfigurationParams , void > = new NotificationType < CustomConfigurationParams , void > ( 'cpptools/didChangeCustomConfiguration' ) ;
236236const CustomBrowseConfigurationNotification : NotificationType < CustomBrowseConfigurationParams , void > = new NotificationType < CustomBrowseConfigurationParams , void > ( 'cpptools/didChangeCustomBrowseConfiguration' ) ;
237237const ClearCustomConfigurationsNotification : NotificationType < void , void > = new NotificationType < void , void > ( 'cpptools/clearCustomConfigurations' ) ;
238+ const ClearCustomBrowseConfigurationNotification : NotificationType < void , void > = new NotificationType < void , void > ( 'cpptools/clearCustomBrowseConfiguration' ) ;
238239const RescanFolderNotification : NotificationType < void , void > = new NotificationType < void , void > ( 'cpptools/rescanFolder' ) ;
239240const DidChangeVisibleRangesNotification : NotificationType < DidChangeVisibleRangesParams , void > = new NotificationType < DidChangeVisibleRangesParams , void > ( 'cpptools/didChangeVisibleRanges' ) ;
240241const SemanticColorizationRegionsReceiptNotification : NotificationType < SemanticColorizationRegionsReceiptParams , void > = new NotificationType < SemanticColorizationRegionsReceiptParams , void > ( 'cpptools/semanticColorizationRegionsReceipt' ) ;
@@ -958,58 +959,60 @@ export class DefaultClient implements Client {
958959 }
959960
960961 public onDidChangeSettings ( event : vscode . ConfigurationChangeEvent ) : { [ key : string ] : string } {
961- let colorizationNeedsReload : boolean = event . affectsConfiguration ( "workbench.colorTheme" )
962- || event . affectsConfiguration ( "editor.tokenColorCustomizations" ) ;
963-
964- let colorizationNeedsRefresh : boolean = colorizationNeedsReload
965- || event . affectsConfiguration ( "C_Cpp.enhancedColorization" , this . RootUri )
966- || event . affectsConfiguration ( "C_Cpp.dimInactiveRegions" , this . RootUri )
967- || event . affectsConfiguration ( "C_Cpp.inactiveRegionOpacity" , this . RootUri )
968- || event . affectsConfiguration ( "C_Cpp.inactiveRegionForegroundColor" , this . RootUri )
969- || event . affectsConfiguration ( "C_Cpp.inactiveRegionBackgroundColor" , this . RootUri ) ;
970-
971- let colorThemeChanged : boolean = event . affectsConfiguration ( "workbench.colorTheme" , this . RootUri ) ;
972- if ( colorThemeChanged ) {
973- let otherSettings : OtherSettings = new OtherSettings ( this . RootUri ) ;
974- this . languageClient . sendNotification ( ColorThemeChangedNotification , { name : otherSettings . colorTheme } ) ;
975- }
962+ let changedSettings : { [ key : string ] : string } = this . settingsTracker . getChangedSettings ( ) ;
963+ this . notifyWhenReady ( ( ) => {
964+ let colorizationNeedsReload : boolean = event . affectsConfiguration ( "workbench.colorTheme" )
965+ || event . affectsConfiguration ( "editor.tokenColorCustomizations" ) ;
966+
967+ let colorizationNeedsRefresh : boolean = colorizationNeedsReload
968+ || event . affectsConfiguration ( "C_Cpp.enhancedColorization" , this . RootUri )
969+ || event . affectsConfiguration ( "C_Cpp.dimInactiveRegions" , this . RootUri )
970+ || event . affectsConfiguration ( "C_Cpp.inactiveRegionOpacity" , this . RootUri )
971+ || event . affectsConfiguration ( "C_Cpp.inactiveRegionForegroundColor" , this . RootUri )
972+ || event . affectsConfiguration ( "C_Cpp.inactiveRegionBackgroundColor" , this . RootUri ) ;
973+
974+ let colorThemeChanged : boolean = event . affectsConfiguration ( "workbench.colorTheme" , this . RootUri ) ;
975+ if ( colorThemeChanged ) {
976+ let otherSettings : OtherSettings = new OtherSettings ( this . RootUri ) ;
977+ this . languageClient . sendNotification ( ColorThemeChangedNotification , { name : otherSettings . colorTheme } ) ;
978+ }
976979
977- if ( colorizationNeedsReload ) {
978- this . colorizationSettings . reload ( ) ;
979- }
980- if ( colorizationNeedsRefresh ) {
981- let processedUris : vscode . Uri [ ] = [ ] ;
982- for ( let e of vscode . window . visibleTextEditors ) {
983- let uri : vscode . Uri = e . document . uri ;
984-
985- // Make sure we don't process the same file multiple times.
986- // colorizationState.onSettingsChanged ensures all visible text editors for that file get
987- // refreshed, after it creates a set of decorators to be shared by all visible instances of the file.
988- if ( ! processedUris . find ( e => e === uri ) ) {
989- processedUris . push ( uri ) ;
990- let colorizationState : ColorizationState = this . colorizationState . get ( uri . toString ( ) ) ;
991- if ( colorizationState ) {
992- colorizationState . onSettingsChanged ( uri ) ;
980+ if ( colorizationNeedsReload ) {
981+ this . colorizationSettings . reload ( ) ;
982+ }
983+ if ( colorizationNeedsRefresh ) {
984+ let processedUris : vscode . Uri [ ] = [ ] ;
985+ for ( let e of vscode . window . visibleTextEditors ) {
986+ let uri : vscode . Uri = e . document . uri ;
987+
988+ // Make sure we don't process the same file multiple times.
989+ // colorizationState.onSettingsChanged ensures all visible text editors for that file get
990+ // refreshed, after it creates a set of decorators to be shared by all visible instances of the file.
991+ if ( ! processedUris . find ( e => e === uri ) ) {
992+ processedUris . push ( uri ) ;
993+ let colorizationState : ColorizationState = this . colorizationState . get ( uri . toString ( ) ) ;
994+ if ( colorizationState ) {
995+ colorizationState . onSettingsChanged ( uri ) ;
996+ }
993997 }
994998 }
995999 }
996- }
997- let changedSettings : { [ key : string ] : string } = this . settingsTracker . getChangedSettings ( ) ;
998- if ( Object . keys ( changedSettings ) . length > 0 ) {
999- if ( changedSettings [ "commentContinuationPatterns" ] ) {
1000- updateLanguageConfigurations ( ) ;
1001- }
1002- if ( changedSettings [ "clang_format_path" ] ) {
1003- let settings : CppSettings = new CppSettings ( this . RootUri ) ;
1004- this . languageClient . sendNotification ( UpdateClangFormatPathNotification , util . resolveVariables ( settings . clangFormatPath , this . AdditionalEnvironment ) ) ;
1005- }
1006- if ( changedSettings [ "intelliSenseCachePath" ] ) {
1007- let settings : CppSettings = new CppSettings ( this . RootUri ) ;
1008- this . languageClient . sendNotification ( UpdateIntelliSenseCachePathNotification , util . resolveCachePath ( settings . intelliSenseCachePath , this . AdditionalEnvironment ) ) ;
1000+ if ( Object . keys ( changedSettings ) . length > 0 ) {
1001+ if ( changedSettings [ "commentContinuationPatterns" ] ) {
1002+ updateLanguageConfigurations ( ) ;
1003+ }
1004+ if ( changedSettings [ "clang_format_path" ] ) {
1005+ let settings : CppSettings = new CppSettings ( this . RootUri ) ;
1006+ this . languageClient . sendNotification ( UpdateClangFormatPathNotification , util . resolveVariables ( settings . clangFormatPath , this . AdditionalEnvironment ) ) ;
1007+ }
1008+ if ( changedSettings [ "intelliSenseCachePath" ] ) {
1009+ let settings : CppSettings = new CppSettings ( this . RootUri ) ;
1010+ this . languageClient . sendNotification ( UpdateIntelliSenseCachePathNotification , util . resolveCachePath ( settings . intelliSenseCachePath , this . AdditionalEnvironment ) ) ;
1011+ }
1012+ this . configuration . onDidChangeSettings ( ) ;
1013+ telemetry . logLanguageServerEvent ( "CppSettingsChange" , changedSettings , null ) ;
10091014 }
1010- this . configuration . onDidChangeSettings ( ) ;
1011- telemetry . logLanguageServerEvent ( "CppSettingsChange" , changedSettings , null ) ;
1012- }
1015+ } ) ;
10131016 return changedSettings ;
10141017 }
10151018
@@ -1179,15 +1182,21 @@ export class DefaultClient implements Client {
11791182
11801183 public updateCustomConfigurations ( requestingProvider ?: CustomConfigurationProvider1 ) : Thenable < void > {
11811184 return this . notifyWhenReady ( ( ) => {
1182- this . clearCustomConfigurations ( ) ;
11831185 if ( ! this . configurationProvider ) {
1186+ this . clearCustomConfigurations ( ) ;
11841187 return ;
11851188 }
11861189 let currentProvider : CustomConfigurationProvider1 = getCustomConfigProviders ( ) . get ( this . configurationProvider ) ;
1187- if ( ! currentProvider || ( requestingProvider && requestingProvider . extensionId !== currentProvider . extensionId ) ) {
1190+ if ( ! currentProvider ) {
1191+ this . clearCustomConfigurations ( ) ;
1192+ return ;
1193+ }
1194+ if ( requestingProvider && requestingProvider . extensionId !== currentProvider . extensionId ) {
1195+ // If we are being called by a configuration provider other than the current one, ignore it.
11881196 return ;
11891197 }
11901198
1199+ this . clearCustomConfigurations ( ) ;
11911200 this . trackedDocuments . forEach ( document => {
11921201 this . provideCustomConfiguration ( document . uri , null ) ;
11931202 } ) ;
@@ -1223,7 +1232,7 @@ export class DefaultClient implements Client {
12231232 // Resume parsing on either resolve or reject, only if parsing was not resumed due to timeout
12241233 let hasCompleted : boolean = false ;
12251234 task ( ) . then ( async config => {
1226- await this . sendCustomBrowseConfiguration ( config , currentProvider . extensionId ) ;
1235+ this . sendCustomBrowseConfiguration ( config , currentProvider . extensionId ) ;
12271236 if ( ! hasCompleted ) {
12281237 hasCompleted = true ;
12291238 if ( currentProvider . version >= Version . v2 ) {
@@ -1243,7 +1252,7 @@ export class DefaultClient implements Client {
12431252 global . setTimeout ( async ( ) => {
12441253 if ( ! hasCompleted ) {
12451254 hasCompleted = true ;
1246- await this . sendCustomBrowseConfiguration ( null , null , true ) ;
1255+ this . sendCustomBrowseConfiguration ( null , null , true ) ;
12471256 if ( currentProvider . version >= Version . v2 ) {
12481257 console . warn ( "Configuration Provider timed out in {0}ms." , configProviderTimeout ) ;
12491258 this . resumeParsing ( ) ;
@@ -1340,7 +1349,7 @@ export class DefaultClient implements Client {
13401349 return this . callTaskWithTimeout ( provideConfigurationAsync , configProviderTimeout , tokenSource ) . then (
13411350 ( configs : SourceFileConfigurationItem [ ] ) => {
13421351 if ( configs && configs . length > 0 ) {
1343- this . sendCustomConfigurations ( configs , false ) ;
1352+ this . sendCustomConfigurations ( configs ) ;
13441353 }
13451354 onFinished ( ) ;
13461355 } ,
@@ -1497,16 +1506,12 @@ export class DefaultClient implements Client {
14971506 return this . queueTask ( request ) ;
14981507 }
14991508
1500- public notifyWhenReady ( notify : ( ) => void , blockingTask ?: boolean ) : Thenable < void > {
1509+ public notifyWhenReady ( notify : ( ) => void ) : Thenable < void > {
15011510 let task : ( ) => Thenable < void > = ( ) => new Promise ( resolve => {
15021511 notify ( ) ;
15031512 resolve ( ) ;
15041513 } ) ;
1505- if ( blockingTask ) {
1506- return this . queueBlockingTask ( task ) ;
1507- } else {
1508- return this . queueTask ( task ) ;
1509- }
1514+ return this . queueTask ( task ) ;
15101515 }
15111516
15121517 /**
@@ -1941,30 +1946,30 @@ export class DefaultClient implements Client {
19411946 c . compilerPath = compilerPathAndArgs . compilerPath ;
19421947 c . compilerArgs = compilerPathAndArgs . additionalArgs ;
19431948 } ) ;
1944- this . notifyWhenReady ( ( ) => {
1945- if ( ! this . doneInitialCustomBrowseConfigurationCheck ) {
1946- // Send the last custom browse configuration we received from this provider.
1947- // This ensures we don't start tag parsing without it, and undo'ing work we have to re-do when the (likely same) browse config arrives
1948- // Should only execute on launch, for the initial delivery of configurations
1949- let lastCustomBrowseConfigurationProviderId : PersistentFolderState < string > = new PersistentFolderState < string > ( "CPP.lastCustomBrowseConfigurationProviderId" , null , this . RootPath ) ;
1950- if ( lastCustomBrowseConfigurationProviderId . Value === configurations [ params . currentConfiguration ] . configurationProvider ) {
1951- let lastCustomBrowseConfiguration : PersistentFolderState < WorkspaceBrowseConfiguration > = new PersistentFolderState < WorkspaceBrowseConfiguration > ( "CPP.lastCustomBrowseConfiguration" , null , this . RootPath ) ;
1952- if ( lastCustomBrowseConfiguration . Value ) {
1953- this . sendCustomBrowseConfiguration ( lastCustomBrowseConfiguration . Value , lastCustomBrowseConfigurationProviderId . Value ) ;
1954- }
1949+ if ( ! this . doneInitialCustomBrowseConfigurationCheck ) {
1950+ // Send the last custom browse configuration we received from this provider.
1951+ // This ensures we don't start tag parsing without it, and undo'ing work we have to re-do when the (likely same) browse config arrives
1952+ // Should only execute on launch, for the initial delivery of configurations
1953+ let lastCustomBrowseConfigurationProviderId : PersistentFolderState < string > = new PersistentFolderState < string > ( "CPP.lastCustomBrowseConfigurationProviderId" , null , this . RootPath ) ;
1954+ if ( isSameProviderExtensionId ( lastCustomBrowseConfigurationProviderId . Value , configurations [ params . currentConfiguration ] . configurationProvider ) ) {
1955+ let lastCustomBrowseConfiguration : PersistentFolderState < WorkspaceBrowseConfiguration > = new PersistentFolderState < WorkspaceBrowseConfiguration > ( "CPP.lastCustomBrowseConfiguration" , null , this . RootPath ) ;
1956+ if ( lastCustomBrowseConfiguration . Value ) {
1957+ this . sendCustomBrowseConfiguration ( lastCustomBrowseConfiguration . Value , lastCustomBrowseConfigurationProviderId . Value ) ;
19551958 }
1956- this . doneInitialCustomBrowseConfigurationCheck = true ;
19571959 }
1958- this . languageClient . sendNotification ( ChangeFolderSettingsNotification , params ) ;
1959- this . model . activeConfigName . Value = configurations [ params . currentConfiguration ] . name ;
1960- } ) . then ( ( ) => {
1961- let newProvider : string = this . configuration . CurrentConfigurationProvider ;
1962- if ( ! isSameProviderExtensionId ( newProvider , this . configurationProvider ) ) {
1963- this . configurationProvider = newProvider ;
1964- this . updateCustomBrowseConfiguration ( ) ;
1965- this . updateCustomConfigurations ( ) ;
1960+ this . doneInitialCustomBrowseConfigurationCheck = true ;
1961+ }
1962+ this . languageClient . sendNotification ( ChangeFolderSettingsNotification , params ) ;
1963+ this . model . activeConfigName . Value = configurations [ params . currentConfiguration ] . name ;
1964+ let newProvider : string = this . configuration . CurrentConfigurationProvider ;
1965+ if ( ! isSameProviderExtensionId ( newProvider , this . configurationProvider ) ) {
1966+ if ( this . configurationProvider ) {
1967+ this . clearCustomBrowseConfiguration ( ) ;
19661968 }
1967- } ) ;
1969+ this . configurationProvider = newProvider ;
1970+ this . updateCustomBrowseConfiguration ( ) ;
1971+ this . updateCustomConfigurations ( ) ;
1972+ }
19681973 }
19691974
19701975 private onSelectedConfigurationChanged ( index : number ) : void {
@@ -1997,7 +2002,7 @@ export class DefaultClient implements Client {
19972002 util . isOptionalArrayOfString ( input . configuration . forcedInclude ) ) ;
19982003 }
19992004
2000- private sendCustomConfigurations ( configs : any , blockingTask ?: boolean ) : void {
2005+ private sendCustomConfigurations ( configs : any ) : void {
20012006 // configs is marked as 'any' because it is untrusted data coming from a 3rd-party. We need to sanitize it before sending it to the language server.
20022007 if ( ! configs || ! ( configs instanceof Array ) ) {
20032008 console . warn ( "discarding invalid SourceFileConfigurationItems[]: " + configs ) ;
@@ -2045,16 +2050,10 @@ export class DefaultClient implements Client {
20452050 configurationItems : sanitized
20462051 } ;
20472052
2048- if ( blockingTask ) {
2049- this . notifyWhenReady ( ( ) => {
2050- this . languageClient . sendNotification ( CustomConfigurationNotification , params ) ;
2051- } , blockingTask ) ;
2052- } else {
2053- this . languageClient . sendNotification ( CustomConfigurationNotification , params ) ;
2054- }
2053+ this . languageClient . sendNotification ( CustomConfigurationNotification , params ) ;
20552054 }
20562055
2057- private sendCustomBrowseConfiguration ( config : any , providerId : string , timeoutOccured ?: boolean ) : Thenable < void > {
2056+ private sendCustomBrowseConfiguration ( config : any , providerId : string , timeoutOccured ?: boolean ) : void {
20582057 let lastCustomBrowseConfiguration : PersistentFolderState < WorkspaceBrowseConfiguration > = new PersistentFolderState < WorkspaceBrowseConfiguration > ( "CPP.lastCustomBrowseConfiguration" , null , this . RootPath ) ;
20592058 let lastCustomBrowseConfigurationProviderId : PersistentFolderState < string > = new PersistentFolderState < string > ( "CPP.lastCustomBrowseConfigurationProviderId" , null , this . RootPath ) ;
20602059 let sanitized : util . Mutable < WorkspaceBrowseConfiguration > ;
@@ -2072,7 +2071,7 @@ export class DefaultClient implements Client {
20722071 break ;
20732072 }
20742073 console . log ( "No browse configuration is available." ) ;
2075- return Promise . resolve ( ) ;
2074+ return ;
20762075 }
20772076
20782077 sanitized = { ...< WorkspaceBrowseConfiguration > config } ;
@@ -2087,7 +2086,7 @@ export class DefaultClient implements Client {
20872086 console . log ( "Falling back to last received browse configuration: " , JSON . stringify ( sanitized , null , 2 ) ) ;
20882087 break ;
20892088 }
2090- return Promise . resolve ( ) ;
2089+ return ;
20912090 }
20922091
20932092 let settings : CppSettings = new CppSettings ( this . RootUri ) ;
@@ -2114,13 +2113,17 @@ export class DefaultClient implements Client {
21142113 browseConfiguration : sanitized
21152114 } ;
21162115
2117- return this . notifyWhenReady ( ( ) => this . languageClient . sendNotification ( CustomBrowseConfigurationNotification , params ) ) ;
2116+ this . languageClient . sendNotification ( CustomBrowseConfigurationNotification , params ) ;
21182117 }
21192118
21202119 private clearCustomConfigurations ( ) : void {
21212120 this . notifyWhenReady ( ( ) => this . languageClient . sendNotification ( ClearCustomConfigurationsNotification ) ) ;
21222121 }
21232122
2123+ private clearCustomBrowseConfiguration ( ) : void {
2124+ this . notifyWhenReady ( ( ) => this . languageClient . sendNotification ( ClearCustomBrowseConfigurationNotification ) ) ;
2125+ }
2126+
21242127 /*********************************************
21252128 * command handlers
21262129 *********************************************/
@@ -2148,11 +2151,12 @@ export class DefaultClient implements Client {
21482151 . then ( ( ) => {
21492152 if ( extensionId ) {
21502153 let provider : CustomConfigurationProvider1 = getCustomConfigProviders ( ) . get ( extensionId ) ;
2151- this . updateCustomConfigurations ( provider ) ;
21522154 this . updateCustomBrowseConfiguration ( provider ) ;
2155+ this . updateCustomConfigurations ( provider ) ;
21532156 telemetry . logLanguageServerEvent ( "customConfigurationProvider" , { "providerId" : extensionId } ) ;
21542157 } else {
21552158 this . clearCustomConfigurations ( ) ;
2159+ this . clearCustomBrowseConfiguration ( ) ;
21562160 }
21572161 } ) ;
21582162 } ) ;
0 commit comments