Skip to content

fix(preview): do not scroll a float past the end of the document - #80

Merged
delphinus merged 1 commit into
mainfrom
fix/preview-scroll-end
Oct 26, 2026
Merged

delphinus merged 1 commit into
mainfrom
fix/preview-scroll-end

Conversation

@delphinus

Copy link
Copy Markdown
Owner

:MdRender preview centers the line under the source cursor. When the whole document fit the float, it still scrolled: with the cursor near the end, the first lines, the heading included, went out of view and the bottom rows were left empty. The float's height was right; only the topline was off.

Change

Session:scroll_to_source_line caps the topline so the last line reaches no higher than the bottom of the window. Every line takes at least one row, so the window stays filled when lines wrap. A long document is still centered on the cursor line.

Tests

  • tests/preview_scroll_test.lua: a document that fits opens at its first line with the cursor on its last line, and a long document is still scrolled to the cursor without empty rows below. The first fails without the change (topline 4 instead of 1).
  • make test and stylua.

The float's height counts rendered lines, not screen rows, so it is too short when lines wrap. That is a separate issue and is not changed here.

🤖 Generated with Claude Code

The float preview centers the line under the source cursor. When the
whole document fit the window, that still scrolled it: with the cursor
near the end, the first lines, the heading included, went out of view
and the bottom rows were left empty.

The topline is now capped so the last line reaches no higher than the
bottom of the window. Every line takes at least one row, so the window
stays filled when lines wrap.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@delphinus
delphinus merged commit 4f6d73a into main Oct 26, 2026
38 checks passed
@delphinus
delphinus deleted the fix/preview-scroll-end branch October 26, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant