diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts index bfed6ef00ef..39cf43ecec4 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts @@ -1635,8 +1635,8 @@ registerAction2(class ChangeCellLanguageAction extends NotebookCellAction undefined, undefined ); diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts b/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts index 994cd2c02c4..5d58380dccc 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.ts @@ -79,7 +79,7 @@ registerAction2(class extends Action2 { }); } - async run(accessor: ServicesAccessor, context?: { id: string, extension: string }): Promise { + async run(accessor: ServicesAccessor, context?: { id: string, extension: string; }): Promise { const notebookKernelService = accessor.get(INotebookKernelService); const editorService = accessor.get(IEditorService); const quickInputService = accessor.get(IQuickInputService); @@ -96,7 +96,7 @@ registerAction2(class extends Action2 { context = undefined; } - const notebook = editor.viewModel.notebookDocument; + const notebook = editor.textModel; const { selected, all } = notebookKernelService.getMatchingKernel(notebook); if (selected && context && selected.id === context.id && ExtensionIdentifier.equals(selected.extension, context.extension)) { @@ -120,10 +120,10 @@ registerAction2(class extends Action2 { } if (!newKernel) { - type KernelPick = IQuickPickItem & { kernel: INotebookKernel }; + type KernelPick = IQuickPickItem & { kernel: INotebookKernel; }; const configButton: IQuickInputButton = { iconClass: ThemeIcon.asClassName(configureKernelIcon), - tooltip: nls.localize('notebook.promptKernel.setDefaultTooltip', "Set as default for '{0}' notebooks", editor.viewModel.viewType) + tooltip: nls.localize('notebook.promptKernel.setDefaultTooltip', "Set as default for '{0}' notebooks", editor.textModel.viewType) }; const picks = all.map(kernel => { const res = { @@ -246,7 +246,7 @@ export class KernelStatus extends Disposable implements IWorkbenchContribution { return; } - const notebook = activeEditor.viewModel?.notebookDocument; + const notebook = activeEditor.textModel; if (notebook) { this._showKernelStatus(notebook); } else { diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.ts b/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.ts index 1448a578b40..87a5c564738 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.ts @@ -31,7 +31,7 @@ export class ToggleCellToolbarPositionAction extends Action2 { const editor = context && context.ui ? (context as INotebookActionContext).notebookEditor : undefined; if (editor && editor.hasModel()) { // from toolbar - const viewType = editor.viewModel.viewType; + const viewType = editor.textModel.viewType; const configurationService = accessor.get(IConfigurationService); const toolbarPosition = configurationService.getValue(CellToolbarLocation); const newConfig = this.togglePosition(viewType, toolbarPosition); diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellDnd.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellDnd.ts index 962f7faf2a5..2c86675d7fe 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellDnd.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellDnd.ts @@ -154,7 +154,7 @@ export class CellDragAndDropController extends Disposable { } private updateInsertIndicator(dropDirection: string, insertionIndicatorAbsolutePos: number) { - const { bottomToolbarGap } = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.viewModel?.viewType); + const { bottomToolbarGap } = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.textModel?.viewType); const insertionIndicatorTop = insertionIndicatorAbsolutePos - this.list.scrollTop + bottomToolbarGap / 2; if (insertionIndicatorTop >= 0) { this.listInsertionIndicator.style.top = `${insertionIndicatorTop}px`; @@ -193,11 +193,11 @@ export class CellDragAndDropController extends Disposable { } } - private _dropImpl(draggedCell: ICellViewModel, dropDirection: 'above' | 'below', ctx: { ctrlKey: boolean, altKey: boolean }, draggedOverCell: ICellViewModel) { + private _dropImpl(draggedCell: ICellViewModel, dropDirection: 'above' | 'below', ctx: { ctrlKey: boolean, altKey: boolean; }, draggedOverCell: ICellViewModel) { const cellTop = this.list.getAbsoluteTopOfElement(draggedOverCell); const cellHeight = this.list.elementHeight(draggedOverCell); const insertionIndicatorAbsolutePos = dropDirection === 'above' ? cellTop : cellTop + cellHeight; - const { bottomToolbarGap } = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.viewModel?.viewType); + const { bottomToolbarGap } = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.textModel?.viewType); const insertionIndicatorTop = insertionIndicatorAbsolutePos - this.list.scrollTop + bottomToolbarGap / 2; const editorHeight = this.notebookEditor.getDomNode().getBoundingClientRect().height; if (insertionIndicatorTop < 0 || insertionIndicatorTop > editorHeight) { @@ -378,7 +378,7 @@ export class CellDragAndDropController extends Disposable { this.setInsertIndicatorVisibility(false); } - public explicitDrop(cell: ICellViewModel, ctx: { dragOffsetY: number, ctrlKey: boolean, altKey: boolean }) { + public explicitDrop(cell: ICellViewModel, ctx: { dragOffsetY: number, ctrlKey: boolean, altKey: boolean; }) { this.currentDraggedCell = undefined; this.setInsertIndicatorVisibility(false); diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts index c1a84e42315..6efea4253fb 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts @@ -266,7 +266,7 @@ abstract class AbstractCellRenderer { return; } - const textModel = this.notebookEditor.viewModel!.notebookDocument; + const textModel = this.notebookEditor.textModel!; const index = textModel.cells.indexOf(templateData.currentRenderedCell.model); if (index < 0) { @@ -518,7 +518,7 @@ export class MarkupCellRenderer extends AbstractCellRenderer implements IListRen } private updateForLayout(element: MarkupCellViewModel, templateData: MarkdownCellRenderTemplate): void { - const indicatorPostion = this.notebookEditor.notebookOptions.computeIndicatorPosition(element.layoutInfo.totalHeight, this.notebookEditor.viewModel?.viewType); + const indicatorPostion = this.notebookEditor.notebookOptions.computeIndicatorPosition(element.layoutInfo.totalHeight, this.notebookEditor.textModel?.viewType); templateData.focusIndicatorBottom.style.top = `${indicatorPostion.bottomIndicatorTop}px`; templateData.focusIndicatorLeft.style.height = `${indicatorPostion.verticalIndicatorHeight}px`; templateData.focusIndicatorRight.style.height = `${indicatorPostion.verticalIndicatorHeight}px`; @@ -933,7 +933,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende private updateForLayout(element: CodeCellViewModel, templateData: CodeCellRenderTemplate): void { const layoutInfo = this.notebookEditor.notebookOptions.getLayoutConfiguration(); - const bottomToolbarDimensions = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.viewModel?.viewType); + const bottomToolbarDimensions = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.textModel?.viewType); templateData.focusIndicatorLeft.style.height = `${element.layoutInfo.indicatorHeight}px`; templateData.focusIndicatorRight.style.height = `${element.layoutInfo.indicatorHeight}px`;