Skip to content

Commit 13b45db

Browse files
committed
repl: Ignore inactive sessions which got cleared - so they are not shown any more
fixes microsoft#62418
1 parent 95ca89b commit 13b45db

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

  • src/vs/workbench/parts/debug/electron-browser

src/vs/workbench/parts/debug/electron-browser/repl.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { transparent, editorForeground } from 'vs/platform/theme/common/colorReg
4949
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
5050
import { FocusSessionActionItem } from 'vs/workbench/parts/debug/browser/debugActionItems';
5151
import { CompletionContext, CompletionList, CompletionProviderRegistry } from 'vs/editor/common/modes';
52+
import { first } from 'vs/base/common/arrays';
5253

5354
const $ = dom.$;
5455

@@ -69,6 +70,7 @@ export interface IPrivateReplService {
6970
clearRepl(): void;
7071
}
7172

73+
const sessionsToIgnore = new Set<IDebugSession>();
7274
export class Repl extends Panel implements IPrivateReplService, IHistoryNavigationWidget {
7375
_serviceBrand: any;
7476

@@ -112,6 +114,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
112114

113115
private registerListeners(): void {
114116
this._register(this.debugService.getViewModel().onDidFocusSession(session => {
117+
sessionsToIgnore.delete(session);
115118
this.selectSession(session);
116119
}));
117120
this._register(this.debugService.onDidNewSession(() => this.updateTitleArea()));
@@ -185,6 +188,14 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
185188
const session: IDebugSession = this.tree.getInput();
186189
if (session) {
187190
session.removeReplExpressions();
191+
if (session.state === State.Inactive) {
192+
// Ignore inactive sessions which got cleared - so they are not shown any more
193+
sessionsToIgnore.add(session);
194+
const focusedSession = this.debugService.getViewModel().focusedSession;
195+
// If there is a focusedSession focus on that one, otherwise just show any other not ignored session
196+
this.selectSession(focusedSession || first(this.debugService.getModel().getSessions(true), s => !sessionsToIgnore.has(s)));
197+
this.updateTitleArea();
198+
}
188199
}
189200
this.replInput.focus();
190201
}
@@ -242,7 +253,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
242253

243254
getActions(): IAction[] {
244255
const result: IAction[] = [];
245-
if (this.debugService.getModel().getSessions(true).length > 1) {
256+
if (this.debugService.getModel().getSessions(true).filter(s => !sessionsToIgnore.has(s)).length > 1) {
246257
result.push(this.selectReplAction);
247258
}
248259
result.push(this.clearReplAction);
@@ -482,7 +493,7 @@ registerEditorCommand(new SuggestCommand({
482493

483494
class SelectReplActionItem extends FocusSessionActionItem {
484495
protected getSessions(): ReadonlyArray<IDebugSession> {
485-
return this.debugService.getModel().getSessions(true);
496+
return this.debugService.getModel().getSessions(true).filter(s => !sessionsToIgnore.has(s));
486497
}
487498
}
488499

0 commit comments

Comments
 (0)