-
Notifications
You must be signed in to change notification settings - Fork 298
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
Fix interactive window debug cell, codelens tracking, go to cell, expand/collapse all from toolbar when focus is not on notebook editor #6469
Changes from 6 commits
fade08c
2bcf7eb
cbc46cb
f2c60f4
78a27a3
39692b3
15c0642
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 |
---|---|---|
|
@@ -151,10 +151,18 @@ export class NativeInteractiveWindowCommandListener { | |
) | ||
); | ||
this.disposableRegistry.push( | ||
commandManager.registerCommand(Commands.ExpandAllCells, () => this.expandAllCells()) | ||
commandManager.registerCommand( | ||
Commands.ExpandAllCells, | ||
(context?: { notebookEditor: { notebookUri: Uri } }) => | ||
this.expandAllCells(context?.notebookEditor.notebookUri) | ||
) | ||
); | ||
this.disposableRegistry.push( | ||
commandManager.registerCommand(Commands.CollapseAllCells, () => this.collapseAllCells()) | ||
commandManager.registerCommand( | ||
Commands.CollapseAllCells, | ||
(context?: { notebookEditor: { notebookUri: Uri } }) => | ||
this.collapseAllCells(context?.notebookEditor.notebookUri) | ||
) | ||
); | ||
this.disposableRegistry.push( | ||
commandManager.registerCommand(Commands.ExportOutputAsNotebook, () => this.exportCells()) | ||
|
@@ -422,15 +430,19 @@ export class NativeInteractiveWindowCommandListener { | |
} | ||
} | ||
|
||
private expandAllCells() { | ||
const interactiveWindow = this.interactiveWindowProvider.activeWindow; | ||
private expandAllCells(uri?: Uri) { | ||
const interactiveWindow = uri | ||
? this.interactiveWindowProvider.windows.find((window) => window.notebookUri!.toString() === uri.toString()) | ||
: this.interactiveWindowProvider.activeWindow; | ||
if (interactiveWindow) { | ||
interactiveWindow.expandAllCells(); | ||
} | ||
} | ||
|
||
private collapseAllCells() { | ||
const interactiveWindow = this.interactiveWindowProvider.activeWindow; | ||
private collapseAllCells(uri?: Uri) { | ||
const interactiveWindow = uri | ||
? this.interactiveWindowProvider.windows.find((window) => window.notebookUri!.toString() === uri.toString()) | ||
: this.interactiveWindowProvider.activeWindow; | ||
if (interactiveWindow) { | ||
interactiveWindow.collapseAllCells(); | ||
} | ||
|
@@ -445,7 +457,7 @@ export class NativeInteractiveWindowCommandListener { | |
|
||
private exportAs(uri?: Uri) { | ||
const interactiveWindow = uri | ||
? this.interactiveWindowProvider.windows.find((window) => window.notebookUri!.toString() === uri.toString()) | ||
? this.interactiveWindowProvider.windows.find((window) => window.notebookUri?.toString() === uri.toString()) | ||
: this.interactiveWindowProvider.activeWindow; | ||
if (interactiveWindow) { | ||
interactiveWindow.exportAs(); | ||
|
@@ -454,7 +466,7 @@ export class NativeInteractiveWindowCommandListener { | |
|
||
private export(uri?: Uri) { | ||
const interactiveWindow = uri | ||
? this.interactiveWindowProvider.windows.find((window) => window.notebookUri!.toString() === uri.toString()) | ||
? this.interactiveWindowProvider.windows.find((window) => window.notebookUri?.toString() === uri.toString()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this 'find matching interactive window' could be on the intearctiveWindowProvider? And then everyone of these functions would use that code instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately we're still using the |
||
: this.interactiveWindowProvider.activeWindow; | ||
if (interactiveWindow) { | ||
interactiveWindow.export(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the code it looks like notebookUri is always defined, but the "!" feels a tiny bit less typesafe here since it is optional on the interface. Would ? accomplish the same thing since undefined won't equal uri.toString()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, looks like you have ? below for exportAs (was just reading on more). Can we use that in these locations as well.