-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Handle reloading of REPL Window #24148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
cfa19b0
139f374
e080a03
112c0f4
6b46945
74a31ef
640e976
48c8686
4a278e7
3a0c4fd
f54ef3a
afa89c9
44bd14d
fc966f5
79a1478
140771b
418c1a3
5698f49
6bb4056
60fbabc
8d7e2ac
992c799
dc6dcb5
435c200
639caaf
c3648f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import { | |
| NotebookEdit, | ||
| WorkspaceEdit, | ||
| workspace, | ||
| Uri, | ||
| } from 'vscode'; | ||
| import { getExistingReplViewColumn } from './replUtils'; | ||
| import { PVSC_EXTENSION_ID } from '../common/constants'; | ||
|
|
@@ -20,21 +21,27 @@ import { PVSC_EXTENSION_ID } from '../common/constants'; | |
| export async function openInteractiveREPL( | ||
| notebookController: NotebookController, | ||
| notebookDocument: NotebookDocument | undefined, | ||
| mementoValue: Uri | undefined, | ||
|
||
| preserveFocus: boolean = true, | ||
| ): Promise<NotebookEditor> { | ||
| let viewColumn = ViewColumn.Beside; | ||
|
|
||
| // Case where NotebookDocument (REPL document already exists in the tab) | ||
| if (notebookDocument) { | ||
| if (mementoValue) { | ||
| // also check if memento value URI tab has file name of Python REPL | ||
| // Cached NotebookDocument exists. | ||
| notebookDocument = await workspace.openNotebookDocument(mementoValue as Uri); | ||
| } else if (notebookDocument) { | ||
| // Case where NotebookDocument (REPL document already exists in the tab) | ||
| const existingReplViewColumn = getExistingReplViewColumn(notebookDocument); | ||
| viewColumn = existingReplViewColumn ?? viewColumn; | ||
| } else if (!notebookDocument) { | ||
| // Case where NotebookDocument doesnt exist, create a blank one. | ||
| // Case where NotebookDocument doesnt exist, or | ||
| // became outdated (untitled.ipynb created without Python extension knowing, effectively taking over original Python REPL's URI) | ||
| notebookDocument = await workspace.openNotebookDocument('jupyter-notebook'); | ||
| } | ||
| const editor = window.showNotebookDocument(notebookDocument!, { | ||
| viewColumn, | ||
| asRepl: 'Python REPL', | ||
| preserveFocus: true, | ||
| preserveFocus, | ||
| }); | ||
| await commands.executeCommand('notebook.selectKernel', { | ||
| editor, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.