Skip to content

Let cell editors grow to fit their content instead of capping at 30 lines #119

Closed

Description

@mna-intend

Description

Every cell with more than 30 lines is clipped to 30 lines and shows its own vertical scrollbar. The notebook then scrolls inside a cell that scrolls inside the page, which makes longer cells unpleasant to read and edit. Native notebook cells in .dib and .ipynb grow to fit their content, so this is a regression for anyone migrating.

The cause is in blazor-wasm/wwwroot/_content/Verso.Blazor.Shared/js/monaco-interop.js, in create() -> applyHeight():

const lineHeight = editor.getOption(monaco.editor.EditorOption.lineHeight);
if (!lineHeight) return false;
const lineCount = editor.getModel().getLineCount();
const minLines = 3;
const maxLines = 30;
const lines = Math.max(minLines, Math.min(maxLines, lineCount));
const padding = 10;
container.style.height = (lines * lineHeight + padding) + 'px';
editor.layout();

Three problems:

  1. maxLines = 30 caps the container, so any longer cell is clipped and Monaco adds a vertical scrollbar. This is the visible symptom, and there is no setting to change it - the extension's ten settings are all about host paths, Python, widgets, language and extension paths, none about the editor.

  2. The height is derived from getModel().getLineCount(), the number of model lines. Monaco exposes editor.getContentHeight() for exactly this, which accounts for wrapped lines, view zones and widgets. With the model line count the box is wrong whenever the rendered height differs from lineCount * lineHeight.

  3. wordWrap is not among the options passed to monaco.editor.create, so Monaco's default 'off' applies and a long line adds a horizontal scrollbar on top.

The same calculation is duplicated in the diff editor path further down the same file, with the same cap.

Expected

A cell grows to fit its content and does not scroll inside itself, the way a cell in a .dib or .ipynb does. If an upper bound is wanted for pathologically long cells, it belongs in settings and should default to unlimited, and word wrap should follow the user's editor setting.

Suggested fix

Size from editor.getContentHeight() and subscribe to editor.onDidContentSizeChange - the supported way to auto-size Monaco. That also removes the retry loop that currently polls until lineHeight becomes measurable.

Steps to Reproduce

  1. Create a .verso notebook.
  2. Add a code cell with more than 30 lines. Any content will do.
  3. Look at the cell: it is 30 lines tall and has its own vertical scrollbar;
    the rest is only reachable by scrolling inside the cell.
  4. Add a cell with one line wider than the editor: a horizontal scrollbar
    appears, because word wrap is left at Monaco's default of 'off'.
  5. The same content in a .dib or .ipynb cell renders at full height.

Error Output

No error. This is a layout issue.

Component

VS Code Extension

Frontend

VS Code

Verso Version

1.2.2

.NET Version

10.0.301

Operating System

Windows 11

Notebook Snippet

// Any cell over 30 lines reproduces it.
var a1 = 1; var a2 = 2; var a3 = 3; var a4 = 4; var a5 = 5;
var a6 = 1; var a7 = 2; var a8 = 3; var a9 = 4; var a10 = 5;
var b1 = 1; var b2 = 2; var b3 = 3; var b4 = 4; var b5 = 5;
var b6 = 1; var b7 = 2; var b8 = 3; var b9 = 4; var b10 = 5;
var c1 = 1; var c2 = 2; var c3 = 3; var c4 = 4; var c5 = 5;
var c6 = 1; var c7 = 2; var c8 = 3; var c9 = 4; var c10 = 5;
var d1 = 1; var d2 = 2; var d3 = 3; var d4 = 4; var d5 = 5;
// line 31 onwards: only reachable by scrolling inside the cell
var d6 = 1; var d7 = 2; var d8 = 3;

Loaded Extensions

none

Severity

Low - cosmetic or minor inconvenience

Checklist

  • I searched existing issues and this hasn't been reported yet
  • I can reproduce this with no third-party extensions loaded

Activity

  1. added
    bug
    on Oct 3, 2026
  2. added
    enhancement
    and removed
    bug
    on Oct 4, 2026
  3. changed the title [-][Bug]: Cell editors are capped at 30 lines and get their own scrollbar instead of growing to fit[/-] [+]Let cell editors grow to fit their content instead of capping at 30 lines[/+] on Oct 4, 2026
  4. TorreyBetts commented on Oct 4, 2026

    @TorreyBetts
    Contributor

    Thanks for digging into this, and for pointing straight at getContentHeight(). That turned out to be the right fix.

    #121 changes how cells are sized. They now take their height from Monaco's own measure of the content, so a long line's scrollbar no longer hides the last line, and the compare view does the same. I kept 30 lines as the default limit, though. Most notebooks are easier to scan and reorder when one big cell can't take over the page. What was really missing is that you couldn't change it and nothing told you it was there. So a cell past the limit now says "Showing 30 of 60 lines". In VS Code it has a Change limit link that opens the new verso.editor.maxLines setting, and verso serve takes --max-cell-lines. Set either one to 0 and cells grow to fit no matter how long they get.

    I left word wrap alone in this change. Cells still use Monaco's default of off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions