Skip to content

Commit 6556870

Browse files
committed
fix test - do not overwrite interactive Editor with a notebook editor
1 parent 70c3b66 commit 6556870

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

extensions/vscode-api-tests/src/singlefolder-tests/interactiveWindow.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async function addCellAndRun(code: string, notebook: vscode.NotebookDocument) {
7373
await saveAllFilesAndCloseAll();
7474
});
7575

76-
test.skip('Can open an interactive window and execute from input box', async () => {
76+
test('Can open an interactive window and execute from input box', async () => {
7777
assert.ok(vscode.workspace.workspaceFolders);
7878
const { notebookEditor, inputUri } = await createInteractiveWindow(defaultKernel);
7979

@@ -89,7 +89,7 @@ async function addCellAndRun(code: string, notebook: vscode.NotebookDocument) {
8989
assert.strictEqual(notebookEditor.notebook.cellAt(0).kind, vscode.NotebookCellKind.Code);
9090
});
9191

92-
test.skip('Interactive window scrolls after execute', async () => {
92+
test('Interactive window scrolls after execute', async () => {
9393
assert.ok(vscode.workspace.workspaceFolders);
9494
const { notebookEditor } = await createInteractiveWindow(defaultKernel);
9595

@@ -103,7 +103,7 @@ async function addCellAndRun(code: string, notebook: vscode.NotebookDocument) {
103103

104104
});
105105

106-
test.skip('Interactive window has the correct kernel', async () => {
106+
test('Interactive window has the correct kernel', async () => {
107107
assert.ok(vscode.workspace.workspaceFolders);
108108
await createInteractiveWindow(defaultKernel);
109109

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class InteractiveDocumentContribution extends Disposable implements IWork
9696
providerDisplayName: 'Interactive Notebook',
9797
displayName: 'Interactive',
9898
filenamePattern: ['*.interactive'],
99-
exclusive: true
99+
exclusive: true,
100+
externalEditor: true
100101
}));
101102
}
102103

src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,12 @@ export class NotebookProviderInfoStore extends Disposable {
278278
throw new Error(`notebook type '${info.id}' ALREADY EXISTS`);
279279
}
280280
this._contributedEditors.set(info.id, info);
281-
const editorRegistration = this._registerContributionPoint(info);
282-
this._contributedEditorDisposables.add(editorRegistration);
281+
let editorRegistration: IDisposable | undefined;
282+
// Don't overwrite editor contributions if they come from elsewhere
283+
if (!info.externalEditor) {
284+
editorRegistration = this._registerContributionPoint(info);
285+
this._contributedEditorDisposables.add(editorRegistration);
286+
}
283287

284288
const mementoObject = this._memento.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE);
285289
mementoObject[NotebookProviderInfoStore.CUSTOM_EDITORS_ENTRY_ID] = Array.from(this._contributedEditors.values());
@@ -289,7 +293,7 @@ export class NotebookProviderInfoStore extends Disposable {
289293
const mementoObject = this._memento.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE);
290294
mementoObject[NotebookProviderInfoStore.CUSTOM_EDITORS_ENTRY_ID] = Array.from(this._contributedEditors.values());
291295
this._memento.saveMemento();
292-
editorRegistration.dispose();
296+
editorRegistration?.dispose();
293297
this._contributedEditors.delete(info.id);
294298
});
295299
}
@@ -637,6 +641,7 @@ export class NotebookService extends Disposable implements INotebookService {
637641
exclusive: data.exclusive,
638642
priority: RegisteredEditorPriority.default,
639643
selectors: [],
644+
externalEditor: !!data.externalEditor
640645
});
641646

642647
info.update({ selectors: data.filenamePattern });

src/vs/workbench/contrib/notebook/common/notebookCommon.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ export interface INotebookContributionData {
533533
displayName: string;
534534
filenamePattern: (string | glob.IRelativePattern | INotebookExclusiveDocumentFilter)[];
535535
exclusive: boolean;
536+
/// Editor contribution is handled elswhere e.g. interactive
537+
externalEditor?: boolean;
536538
}
537539

538540

src/vs/workbench/contrib/notebook/common/notebookProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface NotebookEditorDescriptor {
2020
readonly priority: RegisteredEditorPriority;
2121
readonly providerDisplayName: string;
2222
readonly exclusive: boolean;
23+
readonly externalEditor?: boolean;
2324
}
2425

2526
export class NotebookProviderInfo {
@@ -30,6 +31,7 @@ export class NotebookProviderInfo {
3031
readonly priority: RegisteredEditorPriority;
3132
readonly providerDisplayName: string;
3233
readonly exclusive: boolean;
34+
readonly externalEditor: boolean;
3335

3436
private _selectors: NotebookSelector[];
3537
get selectors() {
@@ -57,6 +59,7 @@ export class NotebookProviderInfo {
5759
transientOutputs: false,
5860
cellContentMetadata: {}
5961
};
62+
this.externalEditor = !!descriptor.externalEditor;
6063
}
6164

6265
update(args: { selectors?: NotebookSelector[]; options?: TransientOptions }) {

0 commit comments

Comments
 (0)