Skip to content

Commit

Permalink
Fix restart/interrupt kernel for interactive window script file (#7241)
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceerhl authored Aug 24, 2021
1 parent f5b5bf3 commit b3d58bf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/7158.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ability to use command palette restart/interrupt from command palette when focus is in a Python file linked to an interactive window.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1185,13 +1185,13 @@
"command": "jupyter.interruptkernel",
"title": "%jupyter.command.jupyter.interruptkernel.title%",
"category": "Jupyter",
"when": "jupyter.haveinteractive && jupyter.ispythonorinteractiveeactive && isWorkspaceTrusted"
"when": "jupyter.ispythonorinteractiveeactive && isWorkspaceTrusted"
},
{
"command": "jupyter.restartkernel",
"title": "%jupyter.command.jupyter.restartkernel.title%",
"category": "Jupyter",
"when": "jupyter.haveinteractive && jupyter.ispythonorinteractiveeactive && isWorkspaceTrusted"
"when": "jupyter.ispythonorinteractiveeactive && isWorkspaceTrusted"
},
{
"command": "jupyter.notebookeditor.undocells",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export class KernelCommandListener implements IDataScienceCommandListener {
const uri =
notebookUri ??
window.activeNotebookEditor?.document.uri ??
this.interactiveWindowProvider.activeWindow?.notebookUri;
this.interactiveWindowProvider.activeWindow?.notebookUri ??
(window.activeTextEditor?.document.uri &&
this.interactiveWindowProvider.get(window.activeTextEditor.document.uri)?.notebookUri);
const document = workspace.notebookDocuments.find((document) => document.uri.toString() === uri?.toString());

if (document === undefined) {
Expand Down Expand Up @@ -122,7 +124,9 @@ export class KernelCommandListener implements IDataScienceCommandListener {
const uri =
notebookUri ??
window.activeNotebookEditor?.document.uri ??
this.interactiveWindowProvider.activeWindow?.notebookUri;
this.interactiveWindowProvider.activeWindow?.notebookUri ??
(window.activeTextEditor?.document.uri &&
this.interactiveWindowProvider.get(window.activeTextEditor.document.uri)?.notebookUri);
const document = workspace.notebookDocuments.find((document) => document.uri.toString() === uri?.toString());

if (document === undefined) {
Expand Down
1 change: 0 additions & 1 deletion src/client/datascience/variablesView/notebookWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ interface IExecutionCountEntry {

// For any class that is monitoring the active notebook document, this class will update you
// when the active notebook changes or if the execution count is updated on the active notebook
// NOTE: Currently this class is only looking at native notebook documents
@injectable()
export class NotebookWatcher implements INotebookWatcher {
public get onDidChangeActiveNotebook(): Event<IActiveNotebookChangedEvent> {
Expand Down

0 comments on commit b3d58bf

Please sign in to comment.