Skip to content

Commit

Permalink
repl: Ignore inactive sessions which got cleared - so they are not sh…
Browse files Browse the repository at this point in the history
…own any more

fixes #62418
  • Loading branch information
isidorn committed Nov 12, 2018
1 parent 95ca89b commit 13b45db
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/vs/workbench/parts/debug/electron-browser/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { transparent, editorForeground } from 'vs/platform/theme/common/colorReg
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { FocusSessionActionItem } from 'vs/workbench/parts/debug/browser/debugActionItems';
import { CompletionContext, CompletionList, CompletionProviderRegistry } from 'vs/editor/common/modes';
import { first } from 'vs/base/common/arrays';

const $ = dom.$;

Expand All @@ -69,6 +70,7 @@ export interface IPrivateReplService {
clearRepl(): void;
}

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

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

private registerListeners(): void {
this._register(this.debugService.getViewModel().onDidFocusSession(session => {
sessionsToIgnore.delete(session);
this.selectSession(session);
}));
this._register(this.debugService.onDidNewSession(() => this.updateTitleArea()));
Expand Down Expand Up @@ -185,6 +188,14 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
const session: IDebugSession = this.tree.getInput();
if (session) {
session.removeReplExpressions();
if (session.state === State.Inactive) {
// Ignore inactive sessions which got cleared - so they are not shown any more
sessionsToIgnore.add(session);
const focusedSession = this.debugService.getViewModel().focusedSession;
// If there is a focusedSession focus on that one, otherwise just show any other not ignored session
this.selectSession(focusedSession || first(this.debugService.getModel().getSessions(true), s => !sessionsToIgnore.has(s)));
this.updateTitleArea();
}
}
this.replInput.focus();
}
Expand Down Expand Up @@ -242,7 +253,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati

getActions(): IAction[] {
const result: IAction[] = [];
if (this.debugService.getModel().getSessions(true).length > 1) {
if (this.debugService.getModel().getSessions(true).filter(s => !sessionsToIgnore.has(s)).length > 1) {
result.push(this.selectReplAction);
}
result.push(this.clearReplAction);
Expand Down Expand Up @@ -482,7 +493,7 @@ registerEditorCommand(new SuggestCommand({

class SelectReplActionItem extends FocusSessionActionItem {
protected getSessions(): ReadonlyArray<IDebugSession> {
return this.debugService.getModel().getSessions(true);
return this.debugService.getModel().getSessions(true).filter(s => !sessionsToIgnore.has(s));
}
}

Expand Down

0 comments on commit 13b45db

Please sign in to comment.