Skip to content

Marking a file reviewed while filtering unreviewed files jumps the tree scroll position #258

Closed

Description

@mishamsk

What is the problem?

After the unreviewed-files filter added in #257 is enabled with F, pressing Space to mark the selected file as reviewed removes it from the filtered tree and advances the selection, but also scrolls the tree so the next selected file is on the last visible row.

This is especially disruptive after skipping many files and starting review from the middle or bottom of the tree. Even when the reviewed file was at the top or middle of the viewport, each review action jumps the next file to the bottom, making it harder to retain visual context.

Steps to reproduce

  1. Open a diff containing enough files for the file tree to scroll.
  2. Press F to show only unreviewed files.
  3. Skip several files so the selection is somewhere in the middle or lower part of the tree.
  4. Press Space to mark the selected file as reviewed.

Actual behavior

The reviewed file disappears and the tree scrolls, placing the next selected file on the last visible row.

How does this solve it?

Preserve the selected row’s approximate viewport position when the reviewed file is removed from the filtered tree. The next selected file should stay where the reviewed file was, unless scrolling is actually required to keep it visible. This removes the unnecessary jump while retaining the automatic advancement introduced in #257.

Version

v1.11.0

Activity

  1. mishamsk commented on Jul 12, 2026

    @mishamsk
    ContributorAuthor

    @melonamin @umputun awesome feature that I asked for. let me know if you'd prefer me fixing this

  2. umputun commented on Jul 13, 2026

    @umputun
    Owner

    yes pls, go for it.

    root cause is selectAfterRebuild (app/ui/sidepane/filetree.go:440) zeroing ft.offset on every filter refresh. The next render's ensureVisible (app/ui/sidepane/sidepane.go:79) then sees the advanced cursor below the window and clamps offset = cursor - height + 1, which pins the next file to the last row. Preserving the offset instead of resetting to 0, and letting ensureVisible scroll only when the selection would otherwise be hidden, should cover it.

  3. added a commit that references this issue on Jul 13, 2026
    44a1b24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions