mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-23 03:39:23 +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);
|
||||
if (cachedOptions) {
|
||||
const cachedOptionsValue = await cachedOptions;
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cachedOptionsValue && areFileConfigurationsEqual(cachedOptionsValue, currentOptions)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let resolve: (x: FileConfiguration | undefined) => void;
|
||||
this.formatOptions.set(document.uri, new Promise<FileConfiguration | undefined>(r => resolve = r));
|
||||
const task = (async () => {
|
||||
try {
|
||||
const response = await this.client.execute('configure', { file, ...currentOptions }, token);
|
||||
return response.type === 'response' ? currentOptions : undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
})();
|
||||
|
||||
const args: Proto.ConfigureRequestArguments = {
|
||||
file,
|
||||
...currentOptions,
|
||||
};
|
||||
try {
|
||||
const response = await this.client.execute('configure', args, token);
|
||||
resolve!(response.type === 'response' ? currentOptions : undefined);
|
||||
} finally {
|
||||
resolve!(undefined);
|
||||
}
|
||||
this.formatOptions.set(document.uri, task);
|
||||
|
||||
await task;
|
||||
}
|
||||
|
||||
public async setGlobalConfigurationFromDocument(
|
||||
|
||||
Reference in New Issue
Block a user