From e012490d2dfda67f96bc406f0ac34a1ae8674ecc Mon Sep 17 00:00:00 2001 From: rebornix Date: Tue, 2 Jun 2020 14:01:55 -0700 Subject: [PATCH] readonly cells should not support join and split --- .../notebook/browser/contrib/coreActions.ts | 2 +- .../notebook/browser/notebookEditorWidget.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts index 01876ba7a71..6280deda0e5 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts @@ -1333,7 +1333,7 @@ registerAction2(class extends NotebookAction { category: NOTEBOOK_ACTIONS_CATEGORY, menu: { id: MenuId.NotebookCellTitle, - when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_CELL_TYPE.isEqualTo('code'), NOTEBOOK_EDITOR_EDITABLE, InputFocusedContext), + when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_CELL_TYPE.isEqualTo('code'), NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_CELL_EDITABLE, InputFocusedContext), order: CellToolbarOrder.SplitCell }, icon: { id: 'codicon/split-vertical' }, diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts index 2263ff20d0e..c11b9e0dd62 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts @@ -896,6 +896,10 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor return null; } + if (!cell.metadata?.editable) { + return null; + } + let splitPoints = cell.getSelectionsStartPosition(); if (splitPoints && splitPoints.length > 0) { await cell.resolveTextModel(); @@ -932,6 +936,10 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor return null; } + if (!cell.metadata?.editable) { + return null; + } + if (constraint && cell.cellKind !== constraint) { return null; } @@ -951,6 +959,10 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor return null; } + if (!above.metadata?.editable) { + return null; + } + await above.resolveTextModel(); if (!above.hasModel()) { return null; @@ -971,6 +983,10 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor return null; } + if (!below.metadata?.editable) { + return null; + } + await cell.resolveTextModel(); if (!cell.hasModel()) { return null; -- GitLab