Skip to content

Commit 75e992c

Browse files
committed
add to disposables
1 parent d2fa22d commit 75e992c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/vs/workbench/contrib/terminal/browser/terminalVoice.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,10 @@ export class TerminalVoiceSession extends Disposable {
126126
this._acceptTranscriptionScheduler!.cancel();
127127
this._sendText();
128128
}
129-
this._marker?.dispose();
130-
this._ghostTextMarker?.dispose();
131-
this._ghostText?.dispose();
132129
this._ghostText = undefined;
133-
this._decoration?.dispose();
134130
this._decoration = undefined;
131+
this._marker = undefined;
132+
this._ghostTextMarker = undefined;
135133
this._cancellationTokenSource?.cancel();
136134
this._disposables.clear();
137135
this._input = '';
@@ -163,11 +161,15 @@ export class TerminalVoiceSession extends Disposable {
163161
if (!this._marker) {
164162
return;
165163
}
164+
this._disposables.add(this._marker);
166165
this._decoration = xterm.registerDecoration({
167166
marker: this._marker,
168167
layer: 'top',
169168
x: xterm.buffer.active.cursorX ?? 0,
170169
});
170+
if (this._decoration) {
171+
this._disposables.add(this._decoration);
172+
}
171173
this._decoration?.onRender((e: HTMLElement) => {
172174
e.classList.add(...ThemeIcon.asClassNameArray(Codicon.micFilled), 'terminal-voice', 'recording');
173175
e.style.transform = onFirstLine ? 'translate(10px, -2px)' : 'translate(-6px, -5px)';
@@ -193,12 +195,16 @@ export class TerminalVoiceSession extends Disposable {
193195
if (!this._ghostTextMarker) {
194196
return;
195197
}
198+
this._disposables.add(this._ghostTextMarker);
196199
const onFirstLine = xterm.buffer.active.cursorY === 0;
197200
this._ghostText = xterm.registerDecoration({
198201
marker: this._ghostTextMarker,
199202
layer: 'top',
200203
x: onFirstLine ? xterm.buffer.active.cursorX + 4 : xterm.buffer.active.cursorX + 1,
201204
});
205+
if (this._ghostText) {
206+
this._disposables.add(this._ghostText);
207+
}
202208
this._ghostText?.onRender((e: HTMLElement) => {
203209
e.classList.add('terminal-voice-progress-text');
204210
e.textContent = text;

0 commit comments

Comments
 (0)