Skip to content

Commit 0f13661

Browse files
authored
Merge pull request microsoft#209464 from microsoft/merogge/disposable-store
use disposableStore for listeners created in render
2 parents 9c892db + 6b91b70 commit 0f13661

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/vs/workbench/contrib/chat/browser/codeBlockPart.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as dom from 'vs/base/browser/dom';
99
import { Button } from 'vs/base/browser/ui/button/button';
1010
import { Codicon } from 'vs/base/common/codicons';
1111
import { Emitter } from 'vs/base/common/event';
12-
import { Disposable } from 'vs/base/common/lifecycle';
12+
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
1313
import { Schemas } from 'vs/base/common/network';
1414
import { URI, UriComponents } from 'vs/base/common/uri';
1515
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration';
@@ -124,6 +124,8 @@ export class CodeBlockPart extends Disposable {
124124
private currentCodeBlockData: ICodeBlockData | undefined;
125125
private currentScrollWidth = 0;
126126

127+
private disposableStore = this._register(new DisposableStore());
128+
127129
constructor(
128130
private readonly options: ChatEditorOptions,
129131
readonly menuId: MenuId,
@@ -336,8 +338,9 @@ export class CodeBlockPart extends Disposable {
336338

337339
this.layout(width);
338340
if (editable) {
339-
this._register(this.editor.onDidFocusEditorWidget(() => TabFocus.setTabFocusMode(true)));
340-
this._register(this.editor.onDidBlurEditorWidget(() => TabFocus.setTabFocusMode(false)));
341+
this.disposableStore.clear();
342+
this.disposableStore.add(this.editor.onDidFocusEditorWidget(() => TabFocus.setTabFocusMode(true)));
343+
this.disposableStore.add(this.editor.onDidBlurEditorWidget(() => TabFocus.setTabFocusMode(false)));
341344
}
342345
this.editor.updateOptions({ ariaLabel: localize('chat.codeBlockLabel', "Code block {0}", data.codeBlockIndex + 1), readOnly: !editable });
343346

0 commit comments

Comments
 (0)