Skip to content

Commit ce90579

Browse files
committed
Use the right constant.
1 parent 3bcc2f6 commit ce90579

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/vs/workbench/contrib/notebook/browser/constants.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ export const EXECUTE_CELL_COMMAND_ID = 'workbench.notebook.cell.execute';
2222
// Cell sizing related
2323
export const CELL_MARGIN = 20;
2424
export const CELL_RUN_GUTTER = 32; // TODO should be dynamic based on execution order width, and runnable enablement
25+
26+
export const EDITOR_TOOLBAR_HEIGHT = 22;
27+
28+
// Top margin of editor
2529
export const EDITOR_TOP_MARGIN = 8;
30+
31+
// Top and bottom padding inside the monaco editor in a cell, which are included in `cell.editorHeight`
2632
export const EDITOR_TOP_PADDING = 8;
2733
export const EDITOR_BOTTOM_PADDING = 8;
28-
export const EDITOR_TOOLBAR_HEIGHT = 22;
2934

3035
// Cell context keys
3136
export const NOTEBOOK_CELL_TYPE_CONTEXT_KEY = 'notebookCellType'; // code, markdown

src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
2424
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
2525
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
2626
import { INotificationService } from 'vs/platform/notification/common/notification';
27-
import { EDITOR_BOTTOM_PADDING, EDITOR_TOOLBAR_HEIGHT, EDITOR_TOP_PADDING, NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY, NOTEBOOK_CELL_TYPE_CONTEXT_KEY } from 'vs/workbench/contrib/notebook/browser/constants';
27+
import { EDITOR_BOTTOM_PADDING, EDITOR_TOOLBAR_HEIGHT, EDITOR_TOP_PADDING, NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY, NOTEBOOK_CELL_TYPE_CONTEXT_KEY, EDITOR_TOP_MARGIN } from 'vs/workbench/contrib/notebook/browser/constants';
2828
import { ExecuteCellAction, INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/contrib/notebookActions';
2929
import { CellEditState, CellRenderTemplate, CellRunState, ICellViewModel, INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
3030
import { CellMenus } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellMenus';
@@ -142,9 +142,9 @@ abstract class AbstractCellRenderer {
142142

143143
if (templateData.focusIndicator) {
144144
if (actions.length) {
145-
templateData.focusIndicator.style.top = `${EDITOR_TOOLBAR_HEIGHT + EDITOR_TOP_PADDING}px`;
145+
templateData.focusIndicator.style.top = `${EDITOR_TOOLBAR_HEIGHT + EDITOR_TOP_MARGIN}px`;
146146
} else {
147-
templateData.focusIndicator.style.top = `${EDITOR_TOP_PADDING}px`;
147+
templateData.focusIndicator.style.top = `${EDITOR_TOP_MARGIN}px`;
148148
}
149149
}
150150
};

src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as model from 'vs/editor/common/model';
1111
import { Range } from 'vs/editor/common/core/range';
1212
import { ICell, NotebookCellMetadata, NotebookDocumentMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
1313
import { CursorAtBoundary, CellFocusMode, CellEditState, CellRunState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
14-
import { EDITOR_TOP_PADDING, EDITOR_TOOLBAR_HEIGHT } from 'vs/workbench/contrib/notebook/browser/constants';
14+
import { EDITOR_TOOLBAR_HEIGHT, EDITOR_TOP_MARGIN } from 'vs/workbench/contrib/notebook/browser/constants';
1515
import { SearchParams } from 'vs/editor/common/model/textModelSearch';
1616

1717
export const NotebookCellMetadataDefaults = {
@@ -259,7 +259,7 @@ export abstract class BaseCellViewModel extends Disposable {
259259
return 0;
260260
}
261261

262-
return this._textEditor.getTopForLineNumber(line) + EDITOR_TOP_PADDING + EDITOR_TOOLBAR_HEIGHT;
262+
return this._textEditor.getTopForLineNumber(line) + EDITOR_TOP_MARGIN + EDITOR_TOOLBAR_HEIGHT;
263263
}
264264

265265
cursorAtBoundary(): CursorAtBoundary {

src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as UUID from 'vs/base/common/uuid';
88
import * as model from 'vs/editor/common/model';
99
import { ITextModelService } from 'vs/editor/common/services/resolverService';
1010
import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer';
11-
import { EDITOR_BOTTOM_PADDING, EDITOR_TOOLBAR_HEIGHT, EDITOR_TOP_PADDING, CELL_MARGIN, CELL_RUN_GUTTER } from 'vs/workbench/contrib/notebook/browser/constants';
11+
import { EDITOR_BOTTOM_PADDING, EDITOR_TOOLBAR_HEIGHT, EDITOR_TOP_PADDING, CELL_MARGIN, CELL_RUN_GUTTER, EDITOR_TOP_MARGIN } from 'vs/workbench/contrib/notebook/browser/constants';
1212
import { CellEditState, ICellViewModel, CellFindMatch, CodeCellLayoutChangeEvent, CodeCellLayoutInfo, NotebookLayoutInfo } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
1313
import { CellKind, ICell, NotebookCellOutputsSplice } from 'vs/workbench/contrib/notebook/common/notebookCommon';
1414
import { BaseCellViewModel } from './baseCellViewModel';
@@ -107,9 +107,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
107107
// recompute
108108
this._ensureOutputsTop();
109109
const outputTotalHeight = this._outputsTop!.getTotalValue();
110-
const totalHeight = this.outputs.length
111-
? EDITOR_TOOLBAR_HEIGHT + this.editorHeight + EDITOR_TOP_PADDING + 16 + outputTotalHeight
112-
: EDITOR_TOOLBAR_HEIGHT + this.editorHeight + EDITOR_TOP_PADDING + EDITOR_BOTTOM_PADDING + outputTotalHeight;
110+
const totalHeight = EDITOR_TOOLBAR_HEIGHT + this.editorHeight + EDITOR_TOP_MARGIN + 16 + outputTotalHeight;
113111
const indicatorHeight = this.editorHeight + outputTotalHeight;
114112
const outputContainerOffset = EDITOR_TOOLBAR_HEIGHT + this.editorHeight;
115113
const editorWidth = state.outerWidth !== undefined ? state.outerWidth - CELL_MARGIN * 2 - CELL_RUN_GUTTER : 0;

0 commit comments

Comments
 (0)