Skip to content

Commit 0a6d820

Browse files
authored
focus on most recent IW input if not in IW (microsoft#160557)
1 parent 8cf99fe commit 0a6d820

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { VSBuffer } from 'vs/base/common/buffer';
77
import { CancellationToken } from 'vs/base/common/cancellation';
8+
import { Iterable } from 'vs/base/common/iterator';
89
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
910
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
1011
import { parse } from 'vs/base/common/marshalling';
@@ -728,6 +729,21 @@ registerAction2(class extends Action2 {
728729
if (editorControl && editorControl.notebookEditor && editorControl.codeEditor) {
729730
editorService.activeEditorPane?.focus();
730731
}
732+
else {
733+
// find and open the most recent interactive window
734+
const openEditors = editorService.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE);
735+
const interactiveWindow = Iterable.find(openEditors, identifier => { return identifier.editor.typeId === InteractiveEditorInput.ID; });
736+
if (interactiveWindow) {
737+
const editorInput = interactiveWindow.editor as InteractiveEditorInput;
738+
const currentGroup = interactiveWindow.groupId;
739+
const editor = await editorService.openEditor(editorInput, currentGroup);
740+
const editorControl = editor?.getControl() as { notebookEditor: NotebookEditorWidget | undefined; codeEditor: CodeEditorWidget } | undefined;
741+
742+
if (editorControl && editorControl.notebookEditor && editorControl.codeEditor) {
743+
editorService.activeEditorPane?.focus();
744+
}
745+
}
746+
}
731747
}
732748
});
733749

0 commit comments

Comments
 (0)