Skip to content

Commit

Permalink
debt - fix some leaks (#240895)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Feb 15, 2025
1 parent cfbc936 commit a948ee5
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/vs/editor/contrib/peekView/browser/peekView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ export abstract class PeekViewWidget extends ZoneWidget {
this._disposables.add(this._actionbarWidget);

if (!noCloseAction) {
this._actionbarWidget.push(new Action('peekview.close', nls.localize('label.close', "Close"), ThemeIcon.asClassName(Codicon.close), true, () => {
this._actionbarWidget.push(this._disposables.add(new Action('peekview.close', nls.localize('label.close', "Close"), ThemeIcon.asClassName(Codicon.close), true, () => {
this.dispose();
return Promise.resolve();
}), { label: false, icon: true });
})), { label: false, icon: true });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export abstract class SimpleFindWidget extends Widget implements IVerticalSashLa
private _foundMatch: boolean = false;
private _width: number = 0;

readonly state: FindReplaceState = new FindReplaceState();
readonly state: FindReplaceState;

constructor(
options: IFindOptions,
Expand All @@ -79,6 +79,7 @@ export abstract class SimpleFindWidget extends Widget implements IVerticalSashLa
) {
super();

this.state = this._register(new FindReplaceState());
this._matchesLimit = options.matchesLimit ?? Number.MAX_SAFE_INTEGER;

this._findInput = this._register(new ContextScopedFindInput(null, contextViewService, {
Expand Down
8 changes: 5 additions & 3 deletions src/vs/workbench/contrib/debug/browser/debugMemory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { DEBUG_MEMORY_SCHEME, IDebugService, IDebugSession, IMemoryInvalidationE

const rangeRe = /range=([0-9]+):([0-9]+)/;

export class DebugMemoryFileSystemProvider implements IFileSystemProvider {
export class DebugMemoryFileSystemProvider extends Disposable implements IFileSystemProvider {
private memoryFdCounter = 0;
private readonly fdMemory = new Map<number, { session: IDebugSession; region: IMemoryRegion }>();
private readonly changeEmitter = new Emitter<readonly IFileChange[]>();
Expand All @@ -31,13 +31,15 @@ export class DebugMemoryFileSystemProvider implements IFileSystemProvider {
| FileSystemProviderCapabilities.FileOpenReadWriteClose;

constructor(private readonly debugService: IDebugService) {
debugService.onDidEndSession(({ session }) => {
super();

this._register(debugService.onDidEndSession(({ session }) => {
for (const [fd, memory] of this.fdMemory) {
if (memory.session === session) {
this.close(fd);
}
}
});
}));
}

public watch(resource: URI, opts: IWatchOptions) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/debug/browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class DebugService implements IDebugService {
if (!this.haveDoneLazySetup) {
// Registering fs providers is slow
// https://github.com/microsoft/vscode/issues/159886
this.disposables.add(this.fileService.registerProvider(DEBUG_MEMORY_SCHEME, new DebugMemoryFileSystemProvider(this)));
this.disposables.add(this.fileService.registerProvider(DEBUG_MEMORY_SCHEME, this.disposables.add(new DebugMemoryFileSystemProvider(this))));
this.haveDoneLazySetup = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class EditSettingRenderer extends Disposable {
associatedPreferencesModel!: IPreferencesEditorModel<ISetting>;
private toggleEditPreferencesForMouseMoveDelayer: Delayer<void>;

private readonly _onUpdateSetting: Emitter<{ key: string; value: any; source: IIndexedSetting }> = new Emitter<{ key: string; value: any; source: IIndexedSetting }>();
private readonly _onUpdateSetting: Emitter<{ key: string; value: any; source: IIndexedSetting }> = this._register(new Emitter<{ key: string; value: any; source: IIndexedSetting }>());
readonly onUpdateSetting: Event<{ key: string; value: any; source: IIndexedSetting }> = this._onUpdateSetting.event;

constructor(private editor: ICodeEditor, private primarySettingsModel: ISettingsEditorModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export abstract class SettingsTreeElement extends Disposable {
parent?: SettingsTreeGroupElement;

private _tabbable = false;
protected readonly _onDidChangeTabbable = new Emitter<void>();
protected readonly _onDidChangeTabbable = this._register(new Emitter<void>());
readonly onDidChangeTabbable = this._onDidChangeTabbable.event;

constructor(_id: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/scm/browser/quickDiffWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class QuickDiffWidget extends PeekViewWidget {
this._actionbarWidget.clear();
this._actionbarWidget.push(actions.reverse(), { label: false, icon: true });
this._actionbarWidget.push([next, previous], { label: false, icon: true });
this._actionbarWidget.push(new Action('peekview.close', nls.localize('label.close', "Close"), ThemeIcon.asClassName(Codicon.close), true, () => this.dispose()), { label: false, icon: true });
this._actionbarWidget.push(this._disposables.add(new Action('peekview.close', nls.localize('label.close', "Close"), ThemeIcon.asClassName(Codicon.close), true, () => this.dispose())), { label: false, icon: true });
}

protected override _fillHead(container: HTMLElement): void {
Expand Down

0 comments on commit a948ee5

Please sign in to comment.