fix: G/END a second time scrolls the last line to the top - #1740
Closed
VXNCXNX wants to merge 1 commit into
Closed
Conversation
the selectable branch only moved the selection, dropping the toggle the non-selectable branch still had. Once the selection is on the last line, further presses now move the top line through the same three cases, so both paths behave identically. Also guard an empty list, where last_line is -1. Fixes tstack#1734.
Owner
This is not acceptable, get out of here. |
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.
Fixes #1734.
What was lost
The non-selectable path still has the toggle you described:
First press puts the last row at the bottom, second press moves the last line to the top, and it alternates from there. The
is_selectable()branch had been reduced to a bareset_selection(last_line), so once the selection reached the last line every further press was a no-op.git log -S tail_bottomtraces the toggle back to 0306287 (2013), so it's the original behavior rather than something inferred.The fix
Rather than duplicating the three cases inside the selectable branch, the two paths now share them. Only the entry condition differs: in a selectable list, the first press moves the selection; after that, presses fall through to exactly the same top-line toggle:
I wrote it as a duplicated three-arm block first, and a review caught that it diverged from the original in one state — top strictly above
tail_bottomwith the selection already on the last line (reachable when the selection is off-screen below, e.g. after a filter change). There the original scrolls to show the tail first; the duplicate jumped straight tolast_line. Sharing the arms removes that class of mistake rather than patching the one instance.Simulated across every reachable state with the selection on the last line:
and the press sequence from a fresh view is
top=10, 20, 10, 20, …with the selection pinned to the last line.Two other details:
std::make_optionalis explicit becauseget_selection()returns an optional, and a bare!= last_linetreats "no selection" as "selection is elsewhere". Correct here by accident, but not something to leave to the reader.last_line == -1, so there's now an earlybreak. Previously that fell intoset_selection(-1), which fired a spuriouslistview_selection_changed.Verification, and its limit
I could not run lnav. autoconf/automake/cmake/pkg-config are absent from my environment, so there's no full build and no
make check, and this is an interactive TUI behavior besides.What I did do is compile the translation unit against the repo's own bundled headers, which does work:
clean with the patch, and it rejects a deliberately introduced typo, so it's a real check rather than a no-op. The state-space comparison above was done by simulating both branches.
Someone able to press
Gtwice in a real lnav would be worth more than either.NEWS.md entry added under v0.14.1.