Repository navigation
Conversation
Capping the topline by buffer line count moves the cursor to the bottom when following wrapped content already fills the screen. Measure the remaining screen rows, stopping before later buffer lines once a window is filled, and use the existing native EOF alignment only when those rows would leave a gap. Keep the original centering path when enough screen rows remain. Add EOF and attached-UI wrapping regressions alongside the upstream tests. Upstream-PR: delphinus#80 (cherry picked from commit 86c7c95)
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.
Opening a preview near the end of a document with wrapped lines can push the current paragraph to the bottom of the window and hide the next paragraph. This change keeps that following text visible in this case while preserving #80's short-document fix.
#80 fixed unnecessary scrolling when a short document already fits the window. Its EOF limit uses buffer line counts, but a buffer line can occupy several screen rows. The limit can therefore pull the view too far toward the start of the document. Neovim then scrolls only enough to bring the mapped cursor back into view at the bottom.
This change measures the screen rows remaining from the proposed starting position. If they fill the window, it applies that position; otherwise it uses Neovim's native bottom alignment. It then places the cursor on the same mapped line. The height query and bottom-alignment command are already used by split synchronization.
The new regression test attaches its own 120×40 UI and checks that the following paragraph is actually drawn. With the same test, #80 fails and this change passes on Neovim 0.12.0 and 0.12.5. The test also covers short-document behavior, EOF alignment, and cursor/source preservation.
Run from this PR's repository root:
Verify the failure on #80 and the fix with the same test
Run these commands from this PR's repository root. Both runs use the PR version of the test; the baseline worktree supplies the unchanged plugin code. The baseline run is expected to exit with status 1 and report
the paragraph after the cursor is off screen.The test creates its own UI, so its result does not depend on your terminal size.
Validation against that upstream base:
make -k testpasses on Neovim 0.12.0 and 0.12.5 (28 Lua test files). The optional PlantUML renderer test is skipped because no renderer is available locally.The change retains the existing initial centering estimate and leaves the floating-window height issue noted in #80 separate.
Reproduce the visible behavior interactively
Save this snippet as a temporary
.vimfile outside the repository. It generates 13 numbered test paragraphs;Para11andPara12are simply the labels for paragraphs 11 and 12:From the repository root of either revision, start a fresh Neovim:
nvim --clean --cmd 'set runtimepath^=.'Resize the terminal so
:echo &columns &linesreports120 40, then run:source /path/to/your/repro.vim. The script places the source cursor in paragraph 11 and opens the tab preview. Before the change, the cursor is on the bottom row and the following paragraph is off screen; with the change, that paragraph is visible below the cursor. Repeat in the other checkout at the same terminal size. Exit each reproduction with:qa!.