Skip to content

Commit e72f70b

Browse files
committed
Fix markdown cell not using real editor height when switching to edit mode
1 parent 180d2ab commit e72f70b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ export class StatefullMarkdownCell extends Disposable {
4343
const viewUpdate = () => {
4444
if (viewCell.editState === CellEditState.Editing) {
4545
// switch to editing mode
46-
const width = viewCell.layoutInfo.editorWidth;
47-
const lineNum = viewCell.lineCount;
48-
const lineHeight = viewCell.layoutInfo.fontInfo?.lineHeight || 17;
49-
const totalHeight = Math.max(lineNum, 1) * lineHeight + EDITOR_TOP_PADDING + EDITOR_BOTTOM_PADDING;
46+
let totalHeight: number;
5047

5148
show(this.editingContainer);
5249
hide(this.markdownContainer);
5350
if (this.editor) {
51+
totalHeight = this.editor!.getContentHeight();
52+
5453
// not first time, we don't need to create editor or bind listeners
5554
viewCell.attachTextEditor(this.editor);
5655
if (notebookEditor.getActiveCell() === viewCell) {
@@ -59,6 +58,11 @@ export class StatefullMarkdownCell extends Disposable {
5958

6059
this.bindEditorListeners(this.editor.getModel()!);
6160
} else {
61+
const width = viewCell.layoutInfo.editorWidth;
62+
const lineNum = viewCell.lineCount;
63+
const lineHeight = viewCell.layoutInfo.fontInfo?.lineHeight || 17;
64+
totalHeight = Math.max(lineNum, 1) * lineHeight + EDITOR_TOP_PADDING + EDITOR_BOTTOM_PADDING;
65+
6266
this.editingContainer.innerHTML = '';
6367
this.editor = instantiationService.createInstance(CodeEditorWidget, this.editingContainer, {
6468
...editorOptions,

0 commit comments

Comments
 (0)