Revert "Fix issue with didOpen processed before initial custom browse config"
This reverts commit 1bddf02180.
This commit is contained in:
@@ -1223,7 +1223,7 @@ export class DefaultClient implements Client {
|
||||
// Resume parsing on either resolve or reject, only if parsing was not resumed due to timeout
|
||||
let hasCompleted: boolean = false;
|
||||
task().then(async config => {
|
||||
this.sendCustomBrowseConfiguration(config, currentProvider.extensionId);
|
||||
await this.sendCustomBrowseConfiguration(config, currentProvider.extensionId);
|
||||
if (!hasCompleted) {
|
||||
hasCompleted = true;
|
||||
if (currentProvider.version >= Version.v2) {
|
||||
@@ -1243,7 +1243,7 @@ export class DefaultClient implements Client {
|
||||
global.setTimeout(async () => {
|
||||
if (!hasCompleted) {
|
||||
hasCompleted = true;
|
||||
this.sendCustomBrowseConfiguration(null, null, true);
|
||||
await this.sendCustomBrowseConfiguration(null, null, true);
|
||||
if (currentProvider.version >= Version.v2) {
|
||||
console.warn("Configuration Provider timed out in {0}ms.", configProviderTimeout);
|
||||
this.resumeParsing();
|
||||
@@ -1340,7 +1340,7 @@ export class DefaultClient implements Client {
|
||||
return this.callTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource).then(
|
||||
(configs: SourceFileConfigurationItem[]) => {
|
||||
if (configs && configs.length > 0) {
|
||||
this.sendCustomConfigurations(configs);
|
||||
this.sendCustomConfigurations(configs, false);
|
||||
}
|
||||
onFinished();
|
||||
},
|
||||
@@ -1497,12 +1497,16 @@ export class DefaultClient implements Client {
|
||||
return this.queueTask(request);
|
||||
}
|
||||
|
||||
public notifyWhenReady(notify: () => void): Thenable<void> {
|
||||
public notifyWhenReady(notify: () => void, blockingTask?: boolean): Thenable<void> {
|
||||
let task: () => Thenable<void> = () => new Promise(resolve => {
|
||||
notify();
|
||||
resolve();
|
||||
});
|
||||
return this.queueTask(task);
|
||||
if (blockingTask) {
|
||||
return this.queueBlockingTask(task);
|
||||
} else {
|
||||
return this.queueTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1937,27 +1941,30 @@ export class DefaultClient implements Client {
|
||||
c.compilerPath = compilerPathAndArgs.compilerPath;
|
||||
c.compilerArgs = compilerPathAndArgs.additionalArgs;
|
||||
});
|
||||
if (!this.doneInitialCustomBrowseConfigurationCheck) {
|
||||
// Send the last custom browse configuration we received from this provider.
|
||||
// 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
|
||||
// Should only execute on launch, for the initial delivery of configurations
|
||||
let lastCustomBrowseConfigurationProviderId: PersistentFolderState<string> = new PersistentFolderState<string>("CPP.lastCustomBrowseConfigurationProviderId", null, this.RootPath);
|
||||
if (isSameProviderExtensionId(lastCustomBrowseConfigurationProviderId.Value, configurations[params.currentConfiguration].configurationProvider)) {
|
||||
let lastCustomBrowseConfiguration: PersistentFolderState<WorkspaceBrowseConfiguration> = new PersistentFolderState<WorkspaceBrowseConfiguration>("CPP.lastCustomBrowseConfiguration", null, this.RootPath);
|
||||
if (lastCustomBrowseConfiguration.Value) {
|
||||
this.sendCustomBrowseConfiguration(lastCustomBrowseConfiguration.Value, lastCustomBrowseConfigurationProviderId.Value);
|
||||
this.notifyWhenReady(() => {
|
||||
if (!this.doneInitialCustomBrowseConfigurationCheck) {
|
||||
// Send the last custom browse configuration we received from this provider.
|
||||
// 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
|
||||
// Should only execute on launch, for the initial delivery of configurations
|
||||
let lastCustomBrowseConfigurationProviderId: PersistentFolderState<string> = new PersistentFolderState<string>("CPP.lastCustomBrowseConfigurationProviderId", null, this.RootPath);
|
||||
if (lastCustomBrowseConfigurationProviderId.Value === configurations[params.currentConfiguration].configurationProvider) {
|
||||
let lastCustomBrowseConfiguration: PersistentFolderState<WorkspaceBrowseConfiguration> = new PersistentFolderState<WorkspaceBrowseConfiguration>("CPP.lastCustomBrowseConfiguration", null, this.RootPath);
|
||||
if (lastCustomBrowseConfiguration.Value) {
|
||||
this.sendCustomBrowseConfiguration(lastCustomBrowseConfiguration.Value, lastCustomBrowseConfigurationProviderId.Value);
|
||||
}
|
||||
}
|
||||
this.doneInitialCustomBrowseConfigurationCheck = true;
|
||||
}
|
||||
this.doneInitialCustomBrowseConfigurationCheck = true;
|
||||
}
|
||||
this.languageClient.sendNotification(ChangeFolderSettingsNotification, params);
|
||||
this.model.activeConfigName.Value = configurations[params.currentConfiguration].name;
|
||||
let newProvider: string = this.configuration.CurrentConfigurationProvider;
|
||||
if (!isSameProviderExtensionId(newProvider, this.configurationProvider)) {
|
||||
this.configurationProvider = newProvider;
|
||||
this.updateCustomBrowseConfiguration();
|
||||
this.updateCustomConfigurations();
|
||||
}
|
||||
this.languageClient.sendNotification(ChangeFolderSettingsNotification, params);
|
||||
this.model.activeConfigName.Value = configurations[params.currentConfiguration].name;
|
||||
}).then(() => {
|
||||
let newProvider: string = this.configuration.CurrentConfigurationProvider;
|
||||
if (!isSameProviderExtensionId(newProvider, this.configurationProvider)) {
|
||||
this.configurationProvider = newProvider;
|
||||
this.updateCustomBrowseConfiguration();
|
||||
this.updateCustomConfigurations();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private onSelectedConfigurationChanged(index: number): void {
|
||||
@@ -1990,7 +1997,7 @@ export class DefaultClient implements Client {
|
||||
util.isOptionalArrayOfString(input.configuration.forcedInclude));
|
||||
}
|
||||
|
||||
private sendCustomConfigurations(configs: any): void {
|
||||
private sendCustomConfigurations(configs: any, blockingTask?: boolean): void {
|
||||
// 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.
|
||||
if (!configs || !(configs instanceof Array)) {
|
||||
console.warn("discarding invalid SourceFileConfigurationItems[]: " + configs);
|
||||
@@ -2038,10 +2045,16 @@ export class DefaultClient implements Client {
|
||||
configurationItems: sanitized
|
||||
};
|
||||
|
||||
this.languageClient.sendNotification(CustomConfigurationNotification, params);
|
||||
if (blockingTask) {
|
||||
this.notifyWhenReady(() => {
|
||||
this.languageClient.sendNotification(CustomConfigurationNotification, params);
|
||||
} , blockingTask);
|
||||
} else {
|
||||
this.languageClient.sendNotification(CustomConfigurationNotification, params);
|
||||
}
|
||||
}
|
||||
|
||||
private sendCustomBrowseConfiguration(config: any, providerId: string, timeoutOccured?: boolean): void {
|
||||
private sendCustomBrowseConfiguration(config: any, providerId: string, timeoutOccured?: boolean): Thenable<void> {
|
||||
let lastCustomBrowseConfiguration: PersistentFolderState<WorkspaceBrowseConfiguration> = new PersistentFolderState<WorkspaceBrowseConfiguration>("CPP.lastCustomBrowseConfiguration", null, this.RootPath);
|
||||
let lastCustomBrowseConfigurationProviderId: PersistentFolderState<string> = new PersistentFolderState<string>("CPP.lastCustomBrowseConfigurationProviderId", null, this.RootPath);
|
||||
let sanitized: util.Mutable<WorkspaceBrowseConfiguration>;
|
||||
@@ -2059,7 +2072,7 @@ export class DefaultClient implements Client {
|
||||
break;
|
||||
}
|
||||
console.log("No browse configuration is available.");
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
sanitized = {...<WorkspaceBrowseConfiguration>config};
|
||||
@@ -2074,7 +2087,7 @@ export class DefaultClient implements Client {
|
||||
console.log("Falling back to last received browse configuration: ", JSON.stringify(sanitized, null, 2));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
let settings: CppSettings = new CppSettings(this.RootUri);
|
||||
@@ -2101,7 +2114,7 @@ export class DefaultClient implements Client {
|
||||
browseConfiguration: sanitized
|
||||
};
|
||||
|
||||
this.languageClient.sendNotification(CustomBrowseConfigurationNotification, params);
|
||||
return this.notifyWhenReady(() => this.languageClient.sendNotification(CustomBrowseConfigurationNotification, params));
|
||||
}
|
||||
|
||||
private clearCustomConfigurations(): void {
|
||||
|
||||
Reference in New Issue
Block a user