mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Check cancellation token earlier and avoid capturing resolve (#166416)
This commit is contained in:
@@ -77,24 +77,27 @@ export default class FileConfigurationManager extends Disposable {
|
|||||||
const cachedOptions = this.formatOptions.get(document.uri);
|
const cachedOptions = this.formatOptions.get(document.uri);
|
||||||
if (cachedOptions) {
|
if (cachedOptions) {
|
||||||
const cachedOptionsValue = await cachedOptions;
|
const cachedOptionsValue = await cachedOptions;
|
||||||
|
if (token.isCancellationRequested) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (cachedOptionsValue && areFileConfigurationsEqual(cachedOptionsValue, currentOptions)) {
|
if (cachedOptionsValue && areFileConfigurationsEqual(cachedOptionsValue, currentOptions)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let resolve: (x: FileConfiguration | undefined) => void;
|
const task = (async () => {
|
||||||
this.formatOptions.set(document.uri, new Promise<FileConfiguration | undefined>(r => resolve = r));
|
try {
|
||||||
|
const response = await this.client.execute('configure', { file, ...currentOptions }, token);
|
||||||
|
return response.type === 'response' ? currentOptions : undefined;
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
const args: Proto.ConfigureRequestArguments = {
|
this.formatOptions.set(document.uri, task);
|
||||||
file,
|
|
||||||
...currentOptions,
|
await task;
|
||||||
};
|
|
||||||
try {
|
|
||||||
const response = await this.client.execute('configure', args, token);
|
|
||||||
resolve!(response.type === 'response' ? currentOptions : undefined);
|
|
||||||
} finally {
|
|
||||||
resolve!(undefined);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setGlobalConfigurationFromDocument(
|
public async setGlobalConfigurationFromDocument(
|
||||||
|
|||||||
Reference in New Issue
Block a user