Repository navigation
fix(preview): do not scroll a float past the end of the document - #80
Merged
Merged
Conversation
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>
This was referenced Oct 26, 2026
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.
:MdRender previewcenters 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_linecaps 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 testand 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