mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
Hook up CancellationToken
This commit is contained in:
@@ -15,6 +15,7 @@ class TagClosing {
|
||||
|
||||
private _disposed = false;
|
||||
private _timeout: NodeJS.Timer | undefined = undefined;
|
||||
private _cancel: vscode.CancellationTokenSource | undefined = undefined;
|
||||
private readonly _disposables: vscode.Disposable[] = [];
|
||||
|
||||
constructor(
|
||||
@@ -27,12 +28,20 @@ class TagClosing {
|
||||
}
|
||||
|
||||
public dispose() {
|
||||
disposeAll(this._disposables);
|
||||
this._disposed = true;
|
||||
|
||||
disposeAll(this._disposables);
|
||||
|
||||
if (this._timeout) {
|
||||
clearTimeout(this._timeout);
|
||||
this._timeout = undefined;
|
||||
}
|
||||
|
||||
if (this._cancel) {
|
||||
this._cancel.cancel();
|
||||
this._cancel.dispose();
|
||||
this._cancel = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
private onDidChangeTextDocument(
|
||||
@@ -53,6 +62,12 @@ class TagClosing {
|
||||
clearTimeout(this._timeout);
|
||||
}
|
||||
|
||||
if (this._cancel) {
|
||||
this._cancel.cancel();
|
||||
this._cancel.dispose();
|
||||
this._cancel = undefined;
|
||||
}
|
||||
|
||||
const lastChange = changes[changes.length - 1];
|
||||
const lastCharacter = lastChange.text[lastChange.text.length - 1];
|
||||
if (lastChange.rangeLength > 0 || lastCharacter !== '>' && lastCharacter !== '/') {
|
||||
@@ -77,8 +92,9 @@ class TagClosing {
|
||||
let body: Proto.TextInsertion | undefined = undefined;
|
||||
const args: Proto.JsxClosingTagRequestArgs = typeConverters.Position.toFileLocationRequestArgs(filepath, position);
|
||||
|
||||
this._cancel = new vscode.CancellationTokenSource();
|
||||
try {
|
||||
const response = await this.client.execute('jsxClosingTag', args, null as any);
|
||||
const response = await this.client.execute('jsxClosingTag', args, this._cancel.token);
|
||||
body = response && response.body;
|
||||
if (!body) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user