fix(editor): the TOC button keeps a gutter to stand on with line numbers off - #812
Merged
Merged
Conversation
…ers off `.toc-toggle-floating` is positioned against the pane — 8px from its left edge, 28px wide — so what it floats over is the line-number gutter. Measured on this Monaco build, contentLeft is 68px with line numbers on (42px of gutter, 26px of line decorations) and 26px with them off, which dropped the button onto the first 10px of every line (#810). Monaco reserves the gutter on `renderType !== Off`, and a render function validates as `Custom`: `() => ''` keeps the width and draws nothing in it, so "off" now lays out exactly as "on" does, minus the digits.
PathGao
force-pushed
the
fix/810-toc-toggle-over-text
branch
from
September 21, 2026 18:45
0eafe63 to
3046aa5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
With "Line Numbers" off and the table of contents collapsed, the floating TOC
button sits on the text. Reported by @felhasznalonev in #810, second bullet, on
2.7.6 / macOS Apple Silicon. Not
Closes: that issue carries six items andthis is one of them.
Mechanism
.toc-toggle-floatingis positioned against the pane, not the editor —left: 8px,width: 28px, so it reaches 36px in. What it floats over is theline-number gutter.
Measured on monaco-editor 0.55.1 with this app's creation options, Menlo 14px:
EditorLayoutInfoComputer.computeLayoutreserves that gutter onrenderType !== Off, and'off'is the only one of the five accepted values thatcollapses it —
'on','relative','interval'and a render function allkeep it. A render function validates as
Custom, so() => ''is "keep thegutter, draw nothing in it": with line numbers off the layout is now identical
to line numbers on, minus the digits.
Scope
reclaims their width. I had a
lineNumbersMinChars: 2here that got it backto 17px, and took it out: the gutter is a multiple of the digit width while
the button is a fixed 28px, so a narrowed gutter reintroduces the overlap
below 8px of effective type (the default 14px at 50% zoom, the minimum 10px
at 70%), and it leaves the button on the line-decoration strip that the full
gutter clears. Matching "on" exactly has neither problem.
tocSide: 'right'is untouched. The button mirrors toright: 8px, wherewhat it covers is the vertical scrollbar rather than text, and nothing is
reported about it.
each one looks like from the source.
Tests
One, in
editorOptionWiring.test.ts. It asserts that "off" does not reachMonaco as
'off'— that it arrives as a function returning'', that thefunction is one module-level value rather than a closure per call (this runs
in an effect, and a fresh arrow would read as a changed option on every
updateOptions), and that the three modes which already reserved the gutterare passed through untouched.
Reverted the change and kept the test: it fails.
Not pinned: the pixel widths. An earlier draft drove
EditorLayoutInfoComputerwith the button's geometry read out ofMarkdownViewer.svelte, which needed two internals declared inmonacoInternals.d.tsand came to about 125 lines for a one-line fix. "Offlays out like on" is the stronger invariant anyway — it survives the button
moving.
Verification
cargo testnot run — nothing undersrc-tauri/changed.Not verified: I have no screenshot of Markpad itself. The layout numbers come
from monaco-editor 0.55.1 driven directly with this app's creation options in
a browser, and the 36px from the stylesheet; that the editor pane starts at
the layout container's left edge is read off the CSS, not measured in the app.