Skip to content

Conversation

@RaphaeleL
Copy link

When pressing '.' (next page) or ',' (previous page), the selection now stays at the bottom or top of the viewport respectively, instead of being centered which caused items to scroll off.

This implements a special case for page navigation as suggested by the maintainer in issue #5017, keeping the cursor position consistent with user expectations for page-based navigation.

Fixes #5017

PR Description

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide) (Tests: Not required - this is a UI behavior fix with straightforward logic. The underlying scroll functions are already tested in scroll_off_margin_test.go)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

When pressing '.' (next page) or ',' (previous page), the selection
now stays at the bottom or top of the viewport respectively, instead
of being centered which caused items to scroll off.

This implements a special case for page navigation as suggested by
the maintainer in issue jesseduffield#5017, keeping the cursor position consistent
with user expectations for page-based navigation.

Fixes jesseduffield#5017
Copy link
Collaborator

@stefanhaller stefanhaller left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, this looks mostly good.

There's one small thing that feels like a regression to me: when you have non-model items at the top of a view, they are no longer scrolled into view when pressing ,. One example is the --- Pending rebase todos --- line at the top of the commits window when rebasing. To reproduce, select the head commit, then press i to enter an interactive rebase, then press . to scroll down one page, and then , to scroll back up. Now the top-most "pick" todo is at the top of the window, and the "Pending rebase todos" line is not visible. Before this branch it was, and when pressing < instead of , it gets scrolled into view too.

I don't have an immediate great idea what to do about it, and I don't have time to wrap my head around what's conceptually wrong here, but if you can think of ways to improve this, that would be great.

list.MoveSelectedLine(delta)
after := list.GetSelectedLineIdx()

if err := self.pushContextIfNotFocused(); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is needed. The method is only called from keybinding handlers, so the view must be focused already, otherwise the binding wouldn't have been dispatched to it.

I realize that this is copied from handleLineChangeAux, but it doesn't seem to be needed there, either (for the same reason), so it might be nice to add a cleanup commit to remove it there, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pressing . to go to the next page skips multiple items

2 participants