提交 2a558708 编写于 作者: R rebornix

Fix #93777. NotebookViewType context key.

上级 d661f7b2
......@@ -34,6 +34,8 @@ export const EDITOR_TOP_PADDING = 8;
export const EDITOR_BOTTOM_PADDING = 8;
// Cell context keys
export const NOTEBOOK_VIEW_TYPE = 'notebookViewType';
export const NOTEBOOK_CELL_TYPE_CONTEXT_KEY = 'notebookCellType'; // code, markdown
export const NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY = 'notebookCellEditable'; // bool
export const NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY = 'notebookCellMarkdownEditMode'; // bool
......
......@@ -24,7 +24,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { EDITOR_BOTTOM_PADDING, EDITOR_TOOLBAR_HEIGHT, EDITOR_TOP_MARGIN, EDITOR_TOP_PADDING, NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY, NOTEBOOK_CELL_TYPE_CONTEXT_KEY, NOTEBOOK_CELL_RUN_STATE_CONTEXT_KEY } from 'vs/workbench/contrib/notebook/browser/constants';
import { EDITOR_BOTTOM_PADDING, EDITOR_TOOLBAR_HEIGHT, EDITOR_TOP_MARGIN, EDITOR_TOP_PADDING, NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY, NOTEBOOK_CELL_TYPE_CONTEXT_KEY, NOTEBOOK_CELL_RUN_STATE_CONTEXT_KEY, NOTEBOOK_VIEW_TYPE } from 'vs/workbench/contrib/notebook/browser/constants';
import { ExecuteCellAction, INotebookCellActionContext, CancelCellAction } from 'vs/workbench/contrib/notebook/browser/contrib/notebookActions';
import { BaseCellRenderTemplate, CellEditState, CellRunState, CodeCellRenderTemplate, ICellViewModel, INotebookEditor, MarkdownCellRenderTemplate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { CellMenus } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellMenus';
......@@ -223,6 +223,7 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
const contextKeyService = this.contextKeyService.createScoped(templateData.container);
contextKeyService.createKey(NOTEBOOK_CELL_TYPE_CONTEXT_KEY, 'markdown');
contextKeyService.createKey(NOTEBOOK_VIEW_TYPE, element.viewType);
const cellEditableKey = contextKeyService.createKey(NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY, !!(element.metadata?.editable));
elementDisposable.add(element.onDidChangeMetadata(() => {
cellEditableKey.set(!!element.metadata?.editable);
......@@ -373,6 +374,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
}
contextKeyService.createKey(NOTEBOOK_CELL_TYPE_CONTEXT_KEY, 'code');
contextKeyService.createKey(NOTEBOOK_VIEW_TYPE, element.viewType);
const cellEditableKey = contextKeyService.createKey(NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY, !!(element.metadata?.editable));
const updateForMetadata = () => {
const metadata = element.getEvaluatedMetadata(this.notebookEditor.viewModel!.notebookDocument.metadata);
......
......@@ -149,6 +149,8 @@ export class CodeCell extends Disposable {
return;
}
const previousOutputHeight = this.viewCell.layoutInfo.outputTotalHeight;
if (this.viewCell.outputs.length) {
this.templateData.outputContainer!.style.display = 'block';
} else {
......@@ -197,7 +199,13 @@ export class CodeCell extends Disposable {
let editorHeight = templateData.editor!.getContentHeight();
viewCell.editorHeight = editorHeight;
this.relayoutCellDebounced();
if (previousOutputHeight === 0 || this.viewCell.layoutInfo.outputTotalHeight === 0) {
// first execution or removing all outputs
this.relayoutCell();
} else {
this.relayoutCellDebounced();
}
}));
if (viewCell.outputs.length > 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册