Skip to content

Keep keyboard selection visible in folder views - #79

Merged
dhh merged 4 commits into
omacom:mainfrom
mitechell:fix/keyboard-scroll-follow
Nov 16, 2026
Merged

dhh merged 4 commits into
omacom:mainfrom
mitechell:fix/keyboard-scroll-follow

Conversation

@mitechell

@mitechell mitechell commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Keeps keyboard-selected items visible in grid, list, and columns using ListView.Contain. Preserves click positioning and range selection.

Adds a regression test for Down-arrow navigation in grid, list, and columns. Each view starts with no cursor and receives 30 Down presses. The test checks that the current item stays visible after every press and that the cursor advances past the initially visible items. All three views fail without the fix and pass with it.

Validation: bin/build passed; LC_ALL=en_US.UTF-8 bin/test passed 197 tests. Reporter confirmed the desktop fix. Two pre-existing sorting failures under C.UTF-8 pass under en_US.UTF-8.

Fixes #98

- Keep the current item visible after keyboard navigation.
- Cover grid, list, and columns with real-view input tests.
@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a non-blocking request to restore the removed test coverage.

Findings

  1. P2 Broader input checks were removed ▶

Summary

The PR keeps keyboard-selected items visible across all three folder views.

  • Keyboard movement keeps the selected folder item visible.

Reviews (4) · Last reviewed commit: "Trim the keyboard scrolling test to the ..." · Reviewed by Greptile

@sebishogun

Copy link
Copy Markdown

Independently verified this fix for the keyboard auto-scrolling bug in #98, also encountered with Omarchy's current Folio 0.4.0-2 package.

I applied this PR's regression tests and the same two-line Selecting.qml change to main at 61b7e20, using Qt 6.12.0 on Linux/amd64. Selecting.qml is unchanged between v0.4.0 and that main revision.

Before the fix, folderKeyboardScrolls fails in all three views (grid, list, columns) because the selected item leaves the viewport. With the fix, all three pass, including Down/Up, Shift+Down selection, clicking, and wheel scrolling.

This verification covers automatic scrolling to the keyboard-selected item; no additional mouse/touchpad scrolling change was needed.

The build and full test suite passed: 199 passed, 0 failed, 0 skipped, with LC_ALL=en_US.UTF-8 and dbus-run-session -- bin/test -V (offscreen Qt).

Two additional regression cases worth covering, beyond the existing tests:

  1. Scroll with the wheel until the selected item is outside the viewport, then press an arrow. Verify that the new selection is brought back into view and that scrolling alone did not change the selection. The current test checks the wheel preserves selection, but stops before resuming keyboard navigation.
  2. With the view scrolled down, clear the cursor as a click on empty space does, then press Down. Verify that the first item is selected and visible in each view. This also exercises FolderGrid's special currentIndex < 0 path.

These are suggestions for additional coverage; the reported bug is already reproduced and covered by this PR's current tests.

- Cover arrow navigation after wheel scrolling the cursor offscreen.
- Cover Down after clearing a cursor in a scrolled view.
- Verify cursor restoration reveals the item and preserves selection.
@mitechell

mitechell commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @sebishogun for independently verifying the fix and suggesting the additional cases. Added both to the real-view tests in 2cbda71.

For grid, list, and columns, the tests now wheel-scroll the selected item completely above the viewport, check that selection is preserved, then press Down and verify the new selection is visible. They also scroll to the end, clear the selection and cursor through the same methods used by an empty-space click, then press Down and verify that item 0 is selected and visible.

Added a direct select(row, true) restoration check as well. It restores an offscreen cursor and verifies visibility while preserving a multi-file selection. Selecting.select() already ends with the guarded positionViewAtIndex(index, ListView.Contain) call.

All three view cases pass offscreen, and LC_ALL=en_US.UTF-8 bin/test passes with 197 tests, 0 failures. The restoration check exercises the view method directly. The desktop Ctrl+1 view-switch sequence has not been separately verified.

@omarchybot omarchybot added bug Something isn't working verified ready and removed ready labels Nov 15, 2026
@omarchybot

Copy link
Copy Markdown
Contributor

Reviewed at 2cbda71. The bug is real, this fixes it, and I found nothing to change.

What was checked. Everything ran on a disposable VM built from the Omarchy ISO, with a real Hyprland session:

  • Reproduction. I made a folder of 300 files, opened it in each view, and pressed Down 50 times. On main (bb94499), the cursor moves to file-050 (file-200 in the grid), the details pane follows it, and the view stays at the top. With this PR merged onto main, the view scrolls with the cursor in all three views.
  • The PR's test. folderKeyboardScrolls fails in grid, list and columns when src/Selecting.qml is put back to main's version, and passes at this head.
  • The suite. At this head: 197 passed, 0 failed. Merged onto current main: 205 passed, 0 failed.
  • The mouse wheel. With the PR, I scrolled the list away with the mouse wheel so the cursor's row was off screen. The view stayed where the wheel left it, and the selection stayed on file-050. The next Down brought file-051 into view.
  • Stepping into a folder in the columns. Arrow keys move the cursor off screen: the list, grid and columns never scroll to it #98 asked whether the new scrolling fights revealNext() when → steps into a folder. I put the cursor on dir-250 at the bottom edge and pressed →. The new column opens at its top, and the parent column keeps dir-250 in view. Down inside it scrolls that column, and ← comes back to dir-250, still in view. Nothing jumps.

The fix uses the views' own positionViewAtIndex(…, ListView.Contain), the call extendTo() and select() already make. cursorMoved() is the one place Qt's own key navigation reaches. Clicks and restores go through moveTo()'s quiet path, so they don't scroll. The wheel never changes currentIndex, so it can't trigger the new code. Re-reading a folder or switching views already scrolled to the cursor through select() on main, so those don't change either.

Before, list: 50 Downs on main, the details pane names file-050 but the list still shows file-000 to file-020
After, list: the same 50 Downs with the PR, file-050 highlighted at the bottom edge
Before, grid: on main the cursor is on file-200 while the grid shows the first rows
After, grid: with the PR, file-200 is outlined on the bottom row
Before, columns: on main the file column stays at the top while the cursor is on file-050
After, columns: with the PR, file-050 is highlighted at the bottom of the file column
With the PR, after scrolling the wheel up: the list shows file-013 to file-033, file-050 stays selected off screen, and the view does not jump back

Second opinion. Codex Medium and muse-wonder via pi (thinking high) each reviewed the diff and the code around it. Neither found anything blocking, and both agreed with the points above. They can read this session's notes, so that agreement is not guaranteed to be independent. Codex noted two small test gaps, neither of which hides this bug. The click step checks the selection count but not which item was clicked. The restore step calls select(row, true) directly instead of going through a real re-read.

Related. I've linked #98, which reports this bug and proposes the same two lines, so it closes when this merges. #18 and #55 by @thisisgm contain the same change to src/Selecting.qml in commit 2364c92 ("Scroll the cursor into view when keys move it"), authored earlier on 11-11. Both are much larger feature pull requests that conflict with main, and neither has a test for this. This pull request is the one that can land the fix by itself, and it adds the regression test. The identical hunk should merge cleanly with either of them later. Thanks to @thisisgm for getting there first, and to @sebishogun for the two extra cases, which are now covered.

What it waits on. The maintainer. folio's Test workflow hasn't run on this pull request yet, because GitHub holds workflows from forks until a maintainer approves them. After that, it is the maintainer's decision.

The test now presses Down past the fold in each view and checks after every press that the cursor stays in sight, which is what fails without the fix, then that the cursor really went thirty items down, so arrows that stopped moving it can't pass for arrows that scroll. The Up, Shift, click, wheel, clear-cursor and restore steps exercised paths that already scrolled, or never scroll, on main, so they passed with or without it. Visibility is checked from the cursor's item in window coordinates, so the columns view needs no reach into its inner list.

The guard before positionViewAtIndex goes too: the view already ignores an index of -1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot

Copy link
Copy Markdown
Contributor

The maintainer asked for the simplest version of this fix that still does the job, so I pushed 4d0cd16 to the branch. The fix is the same, and the test is cut down to the part that catches the bug.

What changed

  • src/Selecting.qml
    • The if (view.currentIndex >= 0) guard is gone, so the fix is now one line.
    • Qt's positionViewAtIndex already does nothing for an index below 0. I checked on a worker: a list scrolled to 572 stayed at 572 after positionViewAtIndex(-1, …), with no warning.
  • folderKeyboardScrolls, down from 128 lines to 62
    • It keeps the grid, list and columns rows. Each view connects the cursor to cursorMoved() separately, and the grid has its own first-Down path.
    • In each view it presses Down 30 times, from no cursor, and after every press checks that the cursor's item is inside the window. Then it checks that the cursor really got at least 29 items down.
    • I dropped the Up, Shift+Down, click, wheel, clear-cursor and restore steps. Those paths already scrolled on main, or never move the cursor, so they passed with or without the fix.
    • The wheel and click behaviour was checked by hand on a worker in the earlier review, and nothing in this change touches it.

What was checked

  • The fix. With src/Selecting.qml put back to main's version, the trimmed test fails in all three views.
  • The progress check. With the loop cut to one press, the "at least 29 items down" check fails in all three views. Without it, a first Down that works followed by Downs that are swallowed would pass every visibility check.
  • The suite. At 4d0cd16 on a worker: 205 passed, 0 failed.

Second opinion. Codex Medium and muse-wonder via pi (thinking high) reviewed the trim in two rounds.

  • In the first round, Codex found the swallowed-keys gap described above, which is why the progress check is there. Codex is credited as co-author on the commit.
  • Codex would also have kept the wheel and click steps. They guard against a different implementation of the fix, not a regression of this one, so I left them out by the maintainer's bar.
  • muse-wonder judged that nothing else can be removed. The second round of both reviewers found nothing. They can read this session's notes, so that agreement is not guaranteed to be independent.

@mitechell, the second paragraph of the description still lists Up/Down, Shift+Down, click and wheel coverage. The test now covers Down past the fold in each view; you may want to update that paragraph.

What it waits on. The maintainer. GitHub holds the Test workflow at 4d0cd16 for approval, because the commit was pushed to a fork. It passed at cfbb91b, which has the same fix.

Comment thread tests/folio_tests.cpp
Comment on lines +5844 to +5849
// Thirty presses take the cursor well past the fold in every view.
for (int i = 0; i < 30; ++i) {
QTest::keyClick(window, Qt::Key_Down);
QTRY_VERIFY(cursorInView());
}
QVERIFY(root->property("cursor").toInt() >= 29);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Broader input checks were removed

The shortened folderKeyboardScrolls test drops checks for Up, Shift+Down, clicks, wheel scrolling, and the selected items. It now checks only Down and cursor visibility. This is non-blocking, but it leaves broken range selection and unwanted scrolling less likely to be caught. Restore the removed checks alongside the visibility checks.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trim was deliberate: the maintainer asked for the smallest test that guards this fix. The removed steps (Up, Shift+Down, a click, wheel scrolling, clearing the cursor and the selected items) all passed on main without the fix, so they did not guard this change; they were regression coverage for other behaviour. The kept test fails in grid, list and columns with Selecting.qml reverted to main, and its index check fails if the first Down works but later ones are swallowed. If broader keyboard and selection coverage is wanted, it belongs in its own test rather than this one. Checked by Claude Opus 5.5 with a second opinion from Codex Medium and muse-wonder High.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right. I treated the omitted cases as a coverage loss without accounting for whether they fail without this fix. Since they pass on main, they don’t guard this regression; the retained test checks both visibility after each Down press and continued cursor advancement. I withdraw the recommendation to restore those checks. Broader keyboard and selection coverage belongs in a separate test.

@dhh
dhh merged commit 2e2a716 into omacom:main Nov 16, 2026
1 check passed
hegjon added a commit to hegjon/hypoland that referenced this pull request Nov 16, 2026
The folio and folio-scroll workloads and the soak's Folio workloads run
one commit of Folio instead of Omarchy's package: 2e2a71633b76
(omacom/folio#79, after 0.5.0), which scrolls the list to the cursor on
Down. Before it the cursor walked off the bottom and folio-scroll
measured the cursor and the details pane, not scrolling, so its numbers
from before do not compare.

scripts/machines/folio.sh builds the commit on the machines into
/opt/folio/<commit>/, next to Omarchy's package, which it leaves alone;
the workloads are skipped where it is not built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mitechell
mitechell deleted the fix/keyboard-scroll-follow branch November 16, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arrow keys move the cursor off screen: the list, grid and columns never scroll to it

4 participants