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

Remove remaining parts of complex notebook editor #172070

Merged
merged 1 commit into from Jan 23, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/vs/base/common/network.ts
Expand Up @@ -57,8 +57,6 @@ export namespace Schemas {

export const vscodeCustomEditor = 'vscode-custom-editor';

export const vscodeNotebook = 'vscode-notebook';

export const vscodeNotebookCell = 'vscode-notebook-cell';

export const vscodeNotebookCellMetadata = 'vscode-notebook-cell-metadata';
Expand Down
49 changes: 2 additions & 47 deletions src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
Expand Up @@ -26,10 +26,10 @@ import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchCo
import { IEditorSerializer, IEditorFactoryRegistry, EditorExtensions } from 'vs/workbench/common/editor';
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor';
import { isCompositeNotebookEditorInput, NotebookEditorInput, NotebookEditorInputOptions } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
import { NotebookEditorInput, NotebookEditorInputOptions } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { NotebookService } from 'vs/workbench/contrib/notebook/browser/services/notebookServiceImpl';
import { CellKind, CellUri, IResolvedNotebookEditorModel, NotebookDocumentBackupData, NotebookWorkingCopyTypeIdentifier, NotebookSetting, ICellOutput, ICell } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { CellKind, CellUri, IResolvedNotebookEditorModel, NotebookWorkingCopyTypeIdentifier, NotebookSetting, ICellOutput, ICell } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService';
Expand All @@ -54,7 +54,6 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import { IWorkingCopyEditorService } from 'vs/workbench/services/workingCopy/common/workingCopyEditorService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILabelService } from 'vs/platform/label/common/label';
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { NotebookRendererMessagingService } from 'vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl';
import { INotebookRendererMessagingService } from 'vs/workbench/contrib/notebook/common/notebookRendererMessagingService';
Expand Down Expand Up @@ -625,49 +624,6 @@ class SimpleNotebookWorkingCopyEditorHandler extends Disposable implements IWork
}
}

class ComplexNotebookWorkingCopyEditorHandler extends Disposable implements IWorkbenchContribution {

constructor(
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IWorkingCopyEditorService private readonly _workingCopyEditorService: IWorkingCopyEditorService,
@IExtensionService private readonly _extensionService: IExtensionService,
@IWorkingCopyBackupService private readonly _workingCopyBackupService: IWorkingCopyBackupService
) {
super();

this._installHandler();
}

private async _installHandler(): Promise<void> {
await this._extensionService.whenInstalledExtensionsRegistered();

this._register(this._workingCopyEditorService.registerHandler({
handles: workingCopy => workingCopy.resource.scheme === Schemas.vscodeNotebook,
isOpen: (workingCopy, editor) => {
if (isCompositeNotebookEditorInput(editor)) {
return !!editor.editorInputs.find(input => isEqual(URI.from({ scheme: Schemas.vscodeNotebook, path: input.resource.toString() }), workingCopy.resource));
}

return editor instanceof NotebookEditorInput && isEqual(URI.from({ scheme: Schemas.vscodeNotebook, path: editor.resource.toString() }), workingCopy.resource);
},
createEditor: async workingCopy => {
// TODO this is really bad and should adopt the `typeId`
// for backups instead of storing that information in the
// backup.
// But since complex notebooks are deprecated, not worth
// pushing for it and should eventually delete this code
// entirely.
const backup = await this._workingCopyBackupService.resolve<NotebookDocumentBackupData>(workingCopy);
if (!backup?.meta) {
throw new Error(`No backup found for Notebook editor: ${workingCopy.resource}`);
}

return NotebookEditorInput.create(this._instantiationService, workingCopy.resource, backup.meta.viewType, { startDirty: true });
}
}));
}
}

class NotebookLanguageSelectorScoreRefine {

constructor(
Expand Down Expand Up @@ -701,7 +657,6 @@ workbenchContributionsRegistry.registerWorkbenchContribution(RegisterSchemasCont
workbenchContributionsRegistry.registerWorkbenchContribution(NotebookEditorManager, LifecyclePhase.Ready);
workbenchContributionsRegistry.registerWorkbenchContribution(NotebookLanguageSelectorScoreRefine, LifecyclePhase.Ready);
workbenchContributionsRegistry.registerWorkbenchContribution(SimpleNotebookWorkingCopyEditorHandler, LifecyclePhase.Ready);
workbenchContributionsRegistry.registerWorkbenchContribution(ComplexNotebookWorkingCopyEditorHandler, LifecyclePhase.Ready);

registerSingleton(INotebookService, NotebookService, InstantiationType.Delayed);
registerSingleton(INotebookEditorWorkerService, NotebookEditorWorkerServiceImpl, InstantiationType.Delayed);
Expand Down
Expand Up @@ -34,7 +34,7 @@ import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebo
import { updateEditorTopPadding } from 'vs/workbench/contrib/notebook/common/notebookOptions';
import { NotebookOutputRendererInfo, NotebookStaticPreloadInfo as NotebookStaticPreloadInfo } from 'vs/workbench/contrib/notebook/common/notebookOutputRenderer';
import { NotebookEditorDescriptor, NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider';
import { ComplexNotebookProviderInfo, INotebookContentProvider, INotebookSerializer, INotebookService, SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService';
import { INotebookSerializer, INotebookService, SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService';
import { DiffEditorInputFactoryFunction, EditorInputFactoryFunction, EditorInputFactoryObject, IEditorResolverService, IEditorType, RegisteredEditorInfo, RegisteredEditorPriority, UntitledEditorInputFactoryFunction } from 'vs/workbench/services/editor/common/editorResolverService';
import { IExtensionService, isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
import { IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
Expand Down Expand Up @@ -410,7 +410,7 @@ export class NotebookService extends Disposable implements INotebookService {

declare readonly _serviceBrand: undefined;

private readonly _notebookProviders = new Map<string, ComplexNotebookProviderInfo | SimpleNotebookProviderInfo>();
private readonly _notebookProviders = new Map<string, SimpleNotebookProviderInfo>();
private _notebookProviderInfoStore: NotebookProviderInfoStore | undefined = undefined;
private get notebookProviderInfoStore(): NotebookProviderInfoStore {
if (!this._notebookProviderInfoStore) {
Expand Down Expand Up @@ -634,7 +634,7 @@ export class NotebookService extends Disposable implements INotebookService {
});
}

private _registerProviderData(viewType: string, data: SimpleNotebookProviderInfo | ComplexNotebookProviderInfo): IDisposable {
private _registerProviderData(viewType: string, data: SimpleNotebookProviderInfo): IDisposable {
if (this._notebookProviders.has(viewType)) {
throw new Error(`notebook provider for viewtype '${viewType}' already exists`);
}
Expand All @@ -646,17 +646,12 @@ export class NotebookService extends Disposable implements INotebookService {
});
}

registerNotebookController(viewType: string, extensionData: NotebookExtensionDescription, controller: INotebookContentProvider): IDisposable {
this.notebookProviderInfoStore.get(viewType)?.update({ options: controller.options });
return this._registerProviderData(viewType, new ComplexNotebookProviderInfo(viewType, controller, extensionData));
}

registerNotebookSerializer(viewType: string, extensionData: NotebookExtensionDescription, serializer: INotebookSerializer): IDisposable {
this.notebookProviderInfoStore.get(viewType)?.update({ options: serializer.options });
return this._registerProviderData(viewType, new SimpleNotebookProviderInfo(viewType, serializer, extensionData));
}

async withNotebookDataProvider(viewType: string): Promise<ComplexNotebookProviderInfo | SimpleNotebookProviderInfo> {
async withNotebookDataProvider(viewType: string): Promise<SimpleNotebookProviderInfo> {
const selected = this.notebookProviderInfoStore.get(viewType);
if (!selected) {
throw new Error(`UNKNOWN notebook type '${viewType}'`);
Expand Down
Expand Up @@ -751,7 +751,7 @@ var requirejs = (function() {
return;
}

if (matchesSomeScheme(data.href, Schemas.http, Schemas.https, Schemas.mailto, Schemas.vscodeNotebookCell, Schemas.vscodeNotebook)) {
if (matchesSomeScheme(data.href, Schemas.http, Schemas.https, Schemas.mailto, Schemas.vscodeNotebookCell)) {
this.openerService.open(data.href, { fromUserGesture: true, fromWorkspace: true });
} else if (!/^[\w\-]+:/.test(data.href)) {
this._handleResourceOpening(data.href);
Expand Down