提交 ed9c404b 编写于 作者: J Johannes Rieken

cleanup notebook argument processor, remove INotebookTextModel#handle and use...

cleanup notebook argument processor, remove INotebookTextModel#handle and use uri instead, https://github.com/microsoft/vscode/issues/105735
上级 53ffabab
......@@ -962,16 +962,13 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
// Serialized INotebookCellActionContext
processArgument: (arg) => {
if (arg && arg.$mid === 12) {
const documentHandle = arg.notebookEditor?.notebookHandle;
const notebookUri = arg.notebookEditor?.notebookUri;
const cellHandle = arg.cell.handle;
for (const value of this._editors) {
if (value[1].editor.notebookData.handle === documentHandle) {
const cell = value[1].editor.notebookData.getCell(cellHandle);
if (cell) {
return cell.cell;
}
}
const data = this._documents.get(notebookUri);
const cell = data?.getCell(cellHandle);
if (cell) {
return cell.cell;
}
}
return arg;
......
......@@ -266,9 +266,9 @@ export class NotebookEditor extends EditorPane {
super.dispose();
}
toJSON(): object {
return {
notebookHandle: this.viewModel?.handle
};
}
// toJSON(): object {
// return {
// notebookHandle: this.viewModel?.handle
// };
// }
}
......@@ -1735,9 +1735,9 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
super.dispose();
}
toJSON(): object {
toJSON(): { notebookUri: URI | undefined } {
return {
notebookHandle: this.viewModel?.handle
notebookUri: this.viewModel?.uri,
};
}
}
......
......@@ -225,7 +225,6 @@ class ModelData implements IDisposable {
}
export class NotebookService extends Disposable implements INotebookService, ICustomEditorViewTypesHandler {
declare readonly _serviceBrand: undefined;
static mainthreadNotebookDocumentHandle: number = 0;
private readonly _notebookProviders = new Map<string, { controller: IMainNotebookController, extensionData: NotebookExtensionDescription }>();
notebookProviderInfoStore: NotebookProviderInfoStore;
notebookRenderersInfoStore: NotebookOutputRendererInfoStore = new NotebookOutputRendererInfoStore();
......@@ -622,7 +621,7 @@ export class NotebookService extends Disposable implements INotebookService, ICu
return notebookModel;
} else {
notebookModel = this._instantiationService.createInstance(NotebookTextModel, NotebookService.mainthreadNotebookDocumentHandle++, viewType, provider.controller.supportBackup, uri);
notebookModel = this._instantiationService.createInstance(NotebookTextModel, viewType, provider.controller.supportBackup, uri);
await provider.controller.createNotebook(notebookModel, backupId);
}
......
......@@ -170,10 +170,6 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
return this._notebook;
}
get handle() {
return this._notebook.handle;
}
get resolvedLanguages() {
return this._notebook.resolvedLanguages;
}
......
......@@ -164,10 +164,9 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
private _operationManager: NotebookOperationManager;
constructor(
public handle: number,
public viewType: string,
public supportBackup: boolean,
public uri: URI,
readonly viewType: string,
readonly supportBackup: boolean,
readonly uri: URI,
@IUndoRedoService private _undoService: IUndoRedoService,
@ITextModelService private _modelService: ITextModelService,
@IModeService private readonly _modeService: IModeService,
......
......@@ -270,7 +270,6 @@ export interface IMetadata {
}
export interface INotebookTextModel {
handle: number;
viewType: string;
metadata: NotebookDocumentMetadata
readonly uri: URI;
......
......@@ -25,7 +25,7 @@ suite('NotebookViewModel', () => {
const modeService = instantiationService.get(IModeService);
test('ctor', function () {
const notebook = new NotebookTextModel(0, 'notebook', false, URI.parse('test'), undoRedoService, textModelService, modeService);
const notebook = new NotebookTextModel('notebook', false, URI.parse('test'), undoRedoService, textModelService, modeService);
const model = new NotebookEditorTestModel(notebook);
const eventDispatcher = new NotebookEventDispatcher();
const viewModel = new NotebookViewModel('notebook', model.notebook, eventDispatcher, null, instantiationService, blukEditService, undoRedoService);
......
......@@ -393,7 +393,7 @@ export function withTestNotebook(instantiationService: TestInstantiationService,
const viewType = 'notebook';
const editor = new TestNotebookEditor();
const notebook = new NotebookTextModel(0, viewType, false, URI.parse('test'), undoRedoService, textModelService, modeService);
const notebook = new NotebookTextModel(viewType, false, URI.parse('test'), undoRedoService, textModelService, modeService);
notebook.initialize(cells.map(cell => {
return {
source: cell[0],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册