Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

[Feature] Auto-highlight current heading in the outline while scrolling

Open Ember-Dawn opened this issue 6 months ago • 2 comments

Is your feature request related to a problem? Please describe.

When working with long Markdown documents, the outline is useful for navigation, but it does not automatically indicate which section I am currently viewing. This makes it harder to understand the current position in the document while scrolling.

Describe the solution you'd like

Please add an auto-highlight feature for the outline.

When the user scrolls through the editor or preview, the corresponding heading in the outline should be highlighted automatically. Clicking a heading in the outline should still jump to that section.

Ideally, this should work with nested headings such as #, ##, ###, etc.

Describe alternatives you've considered

Currently, the user has to manually compare the visible document content with the outline. This works for short files, but it becomes inconvenient for long documents.

Additional context

This is similar to the "scroll spy" behavior found in many Markdown editors and documentation tools, where the current section is highlighted in the table of contents while scrolling.

Ember-Dawn avatar Jun 03 '26 02:06 Ember-Dawn

The preview side of this exists: the outline tracks the active heading while you scroll the preview and highlights it, and scrolls itself to keep it visible.

Your report says "scrolls through the editor or preview", and the editor half is not covered — the scroll listener is attached to the preview element, so in pure editor mode there's nothing to follow.

PathGao avatar Aug 02 '26 21:08 PathGao

Done in #517, and closed automatically by it — a note on what shipped, because it is not quite what the issue asked for.

You asked for the outline to highlight the current heading "while scrolling through the editor or preview". The preview half already worked; the editor half did not, and the reason is worth stating: the outline decided which heading was current by measuring rendered boxes, and only the preview has those. In editor-only mode the preview never scrolls, and in split view it moves only while scroll sync is on — so there was nothing to measure and the highlight sat still.

Both panes now answer with a source line instead, and one rule picks the entry from it. The editor sends a line on every scroll; the preview already computed one for the tab's reading position. So it follows in editor-only mode, in split view, and with scroll sync off.

No setting. The first draft had one, and that was wrong: the outline has always followed the preview unconditionally, so a switch would have made half of one behaviour optional.

#518 adds the part you did not ask for but would have hit next: the outline scrolled with block: 'nearest', so the highlight walked down to the last visible entry and stayed pinned there. It is centred now — the entries either side of where you are stay visible.

Not in a release yet; it will be in the next one.

PathGao avatar Aug 07 '26 10:08 PathGao