mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
Use MutableDisposable in a few more places
This commit is contained in:
parent
bf815f4cc2
commit
65f4b4a159
|
@ -176,6 +176,10 @@ export class MutableDisposable<T extends IDisposable> implements IDisposable {
|
|||
this._value = value;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.value = undefined;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._isDisposed = true;
|
||||
markTracked(this);
|
||||
|
|
|
@ -33,7 +33,7 @@ export class TabCompletionController implements editorCommon.IEditorContribution
|
|||
private _activeSnippets: Snippet[] = [];
|
||||
private _enabled: boolean;
|
||||
private _selectionListener: IDisposable;
|
||||
private _configListener: IDisposable;
|
||||
private readonly _configListener: IDisposable;
|
||||
|
||||
constructor(
|
||||
private readonly _editor: ICodeEditor,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import 'vs/css!./media/progressService';
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { IDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, DisposableStore, MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IProgressService, IProgressOptions, IProgressStep, ProgressLocation, IProgress, emptyProgress, Progress, IProgressCompositeOptions, IProgressNotificationOptions } from 'vs/platform/progress/common/progress';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { StatusbarAlignment, IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
|
||||
|
@ -25,12 +25,12 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
|||
import { EventHelper } from 'vs/base/browser/dom';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export class ProgressService implements IProgressService {
|
||||
export class ProgressService implements IProgressService, IDisposable {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<IProgressService>;
|
||||
|
||||
private readonly _stack: [IProgressOptions, Progress<IProgressStep>][] = [];
|
||||
private _globalStatusEntry: IDisposable;
|
||||
private readonly _globalStatusEntry = new MutableDisposable();
|
||||
|
||||
constructor(
|
||||
@IActivityService private readonly _activityBar: IActivityService,
|
||||
|
@ -42,6 +42,10 @@ export class ProgressService implements IProgressService {
|
|||
@IKeybindingService private readonly _keybindingService: IKeybindingService
|
||||
) { }
|
||||
|
||||
dispose() {
|
||||
this._globalStatusEntry.dispose();
|
||||
}
|
||||
|
||||
withProgress<R = unknown>(options: IProgressOptions, task: (progress: IProgress<IProgressStep>) => Promise<R>, onDidCancel?: () => void): Promise<R> {
|
||||
const { location } = options;
|
||||
if (typeof location === 'string') {
|
||||
|
@ -97,7 +101,7 @@ export class ProgressService implements IProgressService {
|
|||
}
|
||||
|
||||
private _updateWindowProgress(idx: number = 0) {
|
||||
dispose(this._globalStatusEntry);
|
||||
this._globalStatusEntry.clear();
|
||||
|
||||
if (idx < this._stack.length) {
|
||||
const [options, progress] = this._stack[idx];
|
||||
|
@ -128,7 +132,7 @@ export class ProgressService implements IProgressService {
|
|||
return;
|
||||
}
|
||||
|
||||
this._globalStatusEntry = this._statusbarService.addEntry({
|
||||
this._globalStatusEntry.value = this._statusbarService.addEntry({
|
||||
text: `$(sync~spin) ${text}`,
|
||||
tooltip: title
|
||||
}, 'status.progress', localize('status.progress', "Progress Message"), StatusbarAlignment.LEFT);
|
||||
|
|
Loading…
Reference in a new issue