lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Scroll main panel by whole pages?

Open sdegutis opened this issue 4 years ago • 18 comments

Is your feature request related to a problem? Please describe.

I'm used to using git diff, where I have to do f and b to scroll up/down whole pages.

I'd like to scroll up/down the main panel multiple pages in the same way for the same reason.

Describe the solution you'd like

I tried Ctrl-PgUp/Down and Shift-etc and they did not work. Could these be used?

Describe alternatives you've considered

Just dealing with it, but then I thought: why not post a feature request?

Additional context

Cool program everyone. Thanks for making it!

sdegutis avatar Jan 20 '22 20:01 sdegutis

I like the sound of ctrl+pgup/pgdown. If that's actually a thing that we can send to the terminal then I'm on board.

f and b are already used for various keybindings so I'm hesitant to use those.

I'll chuck a good-first-issue label on this. If anybody wants to take a stab, you can search for scrollUpMain in the codebase to see how that works. We need versions of scrollUpView and scrollDownView in pkg/gui/global_handlers.go that take the scroll amount as a parameter, rather than hardcoding to use gui.UserConfig.Gui.ScrollHeight internally. Then we can pass them the height of the view as that parameter to have us scrolling by a whole page.

jesseduffield avatar Jan 20 '22 21:01 jesseduffield

btw @sdegutis if you want to get your hands dirty with Go, this would be a good first start!

jesseduffield avatar Jan 20 '22 21:01 jesseduffield

Sorry, to clarify, I'm requesting we use Shift-PageUp and Shift-PageDown (or Ctrl-).

sdegutis avatar Jan 20 '22 21:01 sdegutis

Tbh I mainly solved this by just setting scroll amount to 10 in config instead of the default of 2 and using the mouse wheel to scroll, so this can be closed if you want.

sdegutis avatar Jan 20 '22 23:01 sdegutis

By the way @jesseduffield when I looked through the src earlier, I was surprised this was written in Go. I assumed it was written using https://www.npmjs.com/package/blessed

sdegutis avatar Jan 21 '22 00:01 sdegutis

Happy to keep this issue open as others have asked about it (even I would like it haha).

Yeah my choice to use Go was really just coincidence because I wanted to learn the language

jesseduffield avatar Jan 21 '22 03:01 jesseduffield

So how do you like Go after learning it?

sdegutis avatar Jan 21 '22 15:01 sdegutis

First of all Awesome tool!

Based on my understanding of https://github.com/jesseduffield/lazygit/issues/1707#issuecomment-1017947410 I have created a PR to try and implement this -> https://github.com/jesseduffield/lazygit/pull/1709

I had to use Alt+f to scroll up a page and Alt+b to scroll down a page since I was not able to figure out how to use other modifiers like Shift or Ctrl

glendsoza avatar Jan 21 '22 17:01 glendsoza

So how do you like Go after learning it?

@sdegutis I'm fairly critical of Go to be honest. I've had enough exposure to Rust to feel that Go is sorely lacking in features. Especially when it comes to code re-use, Go just doesn't have much (if anything) to offer due to lack of both inheritance, mixins/traits, and generics (though generics are on the way). I've done a fairly extensive writeup on my thoughts here

@glendsoza Nice one. I've left a comment on that PR. As commented, there's another PR in flight that's going to make it easier to use shift/ctrl modifiers, and hopefully that'll let us use pgdown/pgup.

jesseduffield avatar Jan 23 '22 05:01 jesseduffield

@jesseduffield I agree, I came to that conclusion maybe 7 years ago. I tried Rust out and I guess it's fine if you need low-level and lightning-fast and ultra-safe code, which I do 0% of the time (and apparently neither does VS Code but it works well enough). I'm going to try my hand at a quick Electron git client in TypeScript one of these days using simple-git.

sdegutis avatar Jan 23 '22 13:01 sdegutis

I also vote for hotkeys for whole page scrolling. C-f/C-b (like manpage) and C-u/C-d (like tig) both feels right to me. It should be configurable so there should just be a default one and let users choose what they like.

zhengpd avatar May 01 '22 11:05 zhengpd

@jesseduffield -- any update on this one? It'd be really lovely to be able to scroll by whole pages.

mattavos avatar May 08 '25 16:05 mattavos

As of v0.50 you can now focus the main view (by pressing 0), and then you can navigate it using all the normal navigation keys like . and , for scrolling by page, or < and > for beginning/end.

stefanhaller avatar May 08 '25 16:05 stefanhaller

Given that we do now have a way of scrolling the main view both by line and by page via focusing it, I wonder if we should update the page-up/page-down keys to actually scroll by page now. Seems like lots of people are surprised that it currently defaults to only scrolling by line.

On the other hand, lots of lazygit users (myself included) have become accustomed to page-up/page-down only scrolling by lines

jesseduffield avatar May 08 '25 22:05 jesseduffield

@jesseduffield In this comment you only talk about scrolling by line vs. scrolling by page, but isn't the bigger difference which view they operate on? I'd expect pgup/pgdown to scroll the current view (by page of course, not by line), not the main view. They would then do exactly the same as , and ., in the same way as home and end do the same as < and >.

This change makes a lot of sense to me, and I'm in favor. We still have two other ways of scrolling the main view (ctrl-d/u and J/K; they are both listed in the keybinding cheat sheets, but are otherwise not very discoverable).

But I'm probably not qualified to judge, because I rarely use the keyboard to scroll the main view; I use two fingers on the trackpad for that.

stefanhaller avatar May 09 '25 07:05 stefanhaller

As a vim user, I'm accustomed to ctrl+u and ctrl+d scrolling by half pages, and that is what I expected in the lazygit diff view (instead, it scrolls one line, just like pg up/dn). I'm very much in favor of making these scroll by page in the diff view.

When I'm staging files for a commit, I'd like to quickly move from file to file, while being able to scroll quickly in the diff without having to switch focus back and forth between the panes.

Ideally, scrolling by line should also be available somehow in this view. One suggestion would be to use ctrl+e and ctrl+y to scroll by line, just like in vim, however, I see that ctrl+e is already in use. ctrl+j and ctrl+k could also be agreeable, and seems to be available.

otytlandsvik avatar May 09 '25 09:05 otytlandsvik

We could also scroll alternative views by alt+down/up or ctrl+down/up

hacker-DOM avatar May 09 '25 10:05 hacker-DOM

I think a modifier + any-navigation keys applying to the current view would be good.

ctrl + , or ctrl + . applying to current view would be great. I also think we should have an alternative for line scrolling on the current view, page-up/down should really do what they say on the box imo.

... I should really offer a PR rather than my opinion

pstefa1707 avatar Jun 03 '25 05:06 pstefa1707

As of v0.50 you can now focus the main view (by pressing 0), and then you can navigate it using all the normal navigation keys like . and , for scrolling by page, or < and > for beginning/end.

Thanks, that's perfect!

DanOpcode avatar Jun 30 '25 07:06 DanOpcode

i think that the current keybind of lazygit (0.52) is fine:

  • ,.: single page (comma, dot)
  • <>: top/bottom (less/greater than;S-, / S-.)
  • kj: single line
  • UP/DN: single line (arrows)
  • PGUP/PGDN: main pane single line (page-up / page-down)
  • C-u/d: main pane single line (i don't use) (ctrl-u / ctrl-d)

i am using workman layout, and not vim.
so, forcing legacy vim needlessly in my throat would very well be an unpleasant change.

goyalyashpal avatar Jul 14 '25 14:07 goyalyashpal

for now is there a workaround that we can do in the configuration? I would be happy if simply pageup and pagedown in their current implementation have a configurable number of lines that will scroll . is that configurable?

or maybe there is a a way to bind a new key to behave like ,. in my (eg) "unstaged changes" frame?

KJ7LNW avatar Aug 03 '25 21:08 KJ7LNW

is that configurable?

@KJ7LNW

gui:
    scrollHeight: 20

sysoleg avatar Aug 10 '25 05:08 sysoleg

is that configurable?

@KJ7LNW

gui:
    scrollHeight: 20

awesome, now it just needs to be configurable as a % of viewport height!

KJ7LNW avatar Aug 10 '25 19:08 KJ7LNW