Skip to content
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

getActiveInteractiveWindow to getActiveOrAssociatedInteractiveWindow #10160

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/interactive-window/commands/exportCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class ExportCommands implements IExportCommands, IDisposable {
// so we need to get the active editor
sourceDocument =
this.notebooks.activeNotebookEditor?.notebook ||
this.interactiveProvider?.getActiveInteractiveWindow()?.notebookDocument;
this.interactiveProvider?.getActiveOrAssociatedInteractiveWindow()?.notebookDocument;
if (!sourceDocument) {
traceInfo('Export called without a valid exportable document active');
return;
Expand Down
4 changes: 2 additions & 2 deletions src/interactive-window/interactiveWindowCommandListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export class InteractiveWindowCommandListener implements IDataScienceCommandList
}

private async removeCellInInteractiveWindow(context?: NotebookCell) {
const interactiveWindow = this.interactiveWindowProvider.getActiveInteractiveWindow();
const interactiveWindow = this.interactiveWindowProvider.getActiveOrAssociatedInteractiveWindow();
const ranges =
context === undefined
? interactiveWindow?.notebookEditor?.selections
Expand Down Expand Up @@ -496,7 +496,7 @@ export class InteractiveWindowCommandListener implements IDataScienceCommandList
(w) => w.notebookUri?.toString() === notebookUri.toString()
);
} else {
targetInteractiveWindow = this.interactiveWindowProvider.getActiveInteractiveWindow();
targetInteractiveWindow = this.interactiveWindowProvider.getActiveOrAssociatedInteractiveWindow();
}
return targetInteractiveWindow;
}
Expand Down
6 changes: 4 additions & 2 deletions src/interactive-window/interactiveWindowProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export class InteractiveWindowProvider
this.raiseOnDidChangeActiveInteractiveWindow();
}

public getActiveInteractiveWindow(): IInteractiveWindow | undefined {
public getActiveOrAssociatedInteractiveWindow(): IInteractiveWindow | undefined {
if (this.activeWindow) {
return this.activeWindow;
}
Expand All @@ -339,7 +339,9 @@ export class InteractiveWindowProvider
const targetInteractiveNotebookEditor =
resource && getResourceType(resource) === 'interactive' ? this.get(resource)?.notebookEditor : undefined;
const activeInteractiveNotebookEditor =
getResourceType(resource) === 'interactive' ? this.getActiveInteractiveWindow()?.notebookEditor : undefined;
getResourceType(resource) === 'interactive'
? this.getActiveOrAssociatedInteractiveWindow()?.notebookEditor
: undefined;

return targetInteractiveNotebookEditor || activeInteractiveNotebookEditor;
}
Expand Down
5 changes: 4 additions & 1 deletion src/interactive-window/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export interface IInteractiveWindowProvider {
* @param owner The URI of a text document which may be associated with an interactive window.
*/
get(owner: Uri): IInteractiveWindow | undefined;
getActiveInteractiveWindow(): IInteractiveWindow | undefined;
/**
* The active interactive window if it has the focus, or the interactive window associated with current active text editor
*/
getActiveOrAssociatedInteractiveWindow(): IInteractiveWindow | undefined;
}

export interface IInteractiveBase extends Disposable {
Expand Down
4 changes: 2 additions & 2 deletions src/platform/common/activeEditorContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ export class ActiveEditorContextService implements IExtensionSingleActivationSer
private updateSelectedKernelContext() {
const document =
this.vscNotebook.activeNotebookEditor?.notebook ||
this.interactiveProvider?.getActiveInteractiveWindow()?.notebookEditor?.notebook;
this.interactiveProvider?.getActiveOrAssociatedInteractiveWindow()?.notebookEditor?.notebook;
if (document && isJupyterNotebook(document) && this.controllers.getSelectedNotebookController(document)) {
this.isJupyterKernelSelected.set(true).catch(noop);
} else {
this.isJupyterKernelSelected.set(false).catch(noop);
}
}
private updateContextOfActiveInteractiveWindowKernel() {
const notebook = this.interactiveProvider?.getActiveInteractiveWindow()?.notebookEditor?.notebook;
const notebook = this.interactiveProvider?.getActiveOrAssociatedInteractiveWindow()?.notebookEditor?.notebook;
const kernel = notebook ? this.kernelProvider.get(notebook.uri) : undefined;
if (kernel) {
const canStart = kernel.status !== 'unknown';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class NotebookWatcher implements INotebookWatcher {
);
}
private getActiveInteractiveWindowDocument() {
const interactiveWindow = this.interactiveWindowProvider.getActiveInteractiveWindow();
const interactiveWindow = this.interactiveWindowProvider.getActiveOrAssociatedInteractiveWindow();
if (!interactiveWindow) {
return;
}
Expand Down