Skip to content

Commit c7e5301

Browse files
authored
fix microsoft#151986. Fix interactive window navigation. (microsoft#154200)
fix microsoft#151986
1 parent f89c103 commit c7e5301

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
99
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
1010
import { parse } from 'vs/base/common/marshalling';
1111
import { Schemas } from 'vs/base/common/network';
12+
import { extname } from 'vs/base/common/resources';
1213
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
1314
import { assertType } from 'vs/base/common/types';
1415
import { URI } from 'vs/base/common/uri';
@@ -25,7 +26,7 @@ import { localize } from 'vs/nls';
2526
import { Action2, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
2627
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
2728
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
28-
import { EditorActivation } from 'vs/platform/editor/common/editor';
29+
import { EditorActivation, IResourceEditorInput } from 'vs/platform/editor/common/editor';
2930
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
3031
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
3132
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
@@ -48,9 +49,10 @@ import { InteractiveEditor } from 'vs/workbench/contrib/interactive/browser/inte
4849
import { InteractiveEditorInput } from 'vs/workbench/contrib/interactive/browser/interactiveEditorInput';
4950
import { IInteractiveHistoryService, InteractiveHistoryService } from 'vs/workbench/contrib/interactive/browser/interactiveHistoryService';
5051
import { NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
52+
import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
5153
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
5254
import * as icons from 'vs/workbench/contrib/notebook/browser/notebookIcons';
53-
import { CellEditType, CellKind, ICellOutput, NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon';
55+
import { CellEditType, CellKind, CellUri, ICellOutput, NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon';
5456
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
5557
import { INotebookContentProvider, INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
5658
import { columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn';
@@ -214,12 +216,26 @@ export class InteractiveDocumentContribution extends Disposable implements IWork
214216
priority: RegisteredEditorPriority.exclusive
215217
},
216218
{
217-
canSupportResource: uri => uri.scheme === Schemas.vscodeInteractive,
219+
canSupportResource: uri => uri.scheme === Schemas.vscodeInteractive || (uri.scheme === Schemas.vscodeNotebookCell && extname(uri) === '.interactive'),
218220
singlePerResource: true
219221
},
220-
({ resource }) => {
221-
const editorInput = editorService.getEditors(EditorsOrder.SEQUENTIAL).find(editor => editor.editor instanceof InteractiveEditorInput && editor.editor.resource?.toString() === resource.toString());
222-
return editorInput!;
222+
({ resource, options }) => {
223+
const data = CellUri.parse(resource);
224+
let notebookUri: URI = resource;
225+
let cellOptions: IResourceEditorInput | undefined;
226+
227+
if (data) {
228+
notebookUri = data.notebook;
229+
cellOptions = { resource, options };
230+
}
231+
232+
const notebookOptions = { ...options, cellOptions } as INotebookEditorOptions;
233+
234+
const editorInput = editorService.getEditors(EditorsOrder.SEQUENTIAL).find(editor => editor.editor instanceof InteractiveEditorInput && editor.editor.resource?.toString() === notebookUri.toString());
235+
return {
236+
editor: editorInput!.editor,
237+
options: notebookOptions
238+
};
223239
}
224240
);
225241
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
2222
import { EditorPaneSelectionChangeReason, IEditorMemento, IEditorOpenContext, IEditorPaneSelectionChangeEvent } from 'vs/workbench/common/editor';
2323
import { getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
2424
import { InteractiveEditorInput } from 'vs/workbench/contrib/interactive/browser/interactiveEditorInput';
25-
import { ICellViewModel, INotebookEditorViewState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
25+
import { ICellViewModel, INotebookEditorOptions, INotebookEditorViewState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
2626
import { NotebookEditorExtensionsRegistry } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
2727
import { IBorrowValue, INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
2828
import { cellEditorBackground, NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
@@ -501,6 +501,11 @@ export class InteractiveEditor extends EditorPane {
501501
this.#syncWithKernel();
502502
}
503503

504+
override setOptions(options: INotebookEditorOptions | undefined): void {
505+
this.#notebookWidget.value?.setOptions(options);
506+
super.setOptions(options);
507+
}
508+
504509
#toEditorPaneSelectionChangeReason(e: ICursorPositionChangedEvent): EditorPaneSelectionChangeReason {
505510
switch (e.source) {
506511
case TextEditorSelectionSource.PROGRAMMATIC: return EditorPaneSelectionChangeReason.PROGRAMMATIC;

0 commit comments

Comments
 (0)