Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to navigate Block sub-menus with same key (1 .. 5) #3789

Closed
werkz-by-drake opened this issue Aug 2, 2024 · 12 comments
Closed

Option to navigate Block sub-menus with same key (1 .. 5) #3789

werkz-by-drake opened this issue Aug 2, 2024 · 12 comments
Labels
enhancement New feature or request

Comments

@werkz-by-drake
Copy link

Is your feature request related to a problem? Please describe.
I'm always frustrated when I want to navigate to a sub-panel like Remotes or Worktrees and I have to Press '1-5' followed by ']' some number of times.

Describe the solution you'd like
I'd really like it if I could just hit '2' twice to show Worktrees, or '3' twice to show Remotes. Just cycle through the submenus each time I repeat the key.

Describe alternatives you've considered
I tried checking if it were possible to implement it as a custom command, but I haven't seen any examples of custom commands that operate on lazygit itself (I skimmed the compendium).

@werkz-by-drake werkz-by-drake added the enhancement New feature or request label Aug 2, 2024
@stefanhaller
Copy link
Collaborator

Good idea, and shouldn't be hard to do (I think; didn't check yet).

There's one problem though: currently, the number keys simply focus the panel but don't go to tab one; they stay in whatever tab is active. This means that you still need to look at the screen to decide how many times you need to press 2 to get to the "Worktrees" tab, for example. In other words, you can't just remember 2 2 to go to "Worktrees", in your muscle memory.

To improve this, we would have to change the number keys so that they jump to the first tab if the panel wasn't already active; that's a breaking change though which might be annoying for some people. (Or maybe not, who knows.) So maybe we'd need a config for that behavior.

Keen to hear everybody's opinions. @jesseduffield?

@jesseduffield
Copy link
Owner

This is interesting.

  • I like the idea of easily being able to jump to a particular tab
  • I agree that it's awkward if you can't rely on muscle memory
  • I think resetting the the tab upon jump to optimise for muscle memory could be disruptive

But I'm also open to hearing opinions. Arguably the typical user is not changing tabs very often so they wouldn't notice if we reset the tab upon jumping. Pressing the number key is kinda a pro-behaviour anyway; and pros would appreciate the muscle memory optimisation more than regular users.

I personally don't use number keys to jump to panels; I just use left/right arrow keys, so I can't really speak from experience.

@riandrake
Copy link

Thanks for the response!

I would appreciate it to be configurable so I could try it out - but my intuition tells me that I would personally not opt for it to reset to the first tab.

This is because I presume it would require a timeout, and I'm not a fan of timeouts because they either surprise me or stress me out, so I always turn them off (on leader keys, for example).

If I wasn't sure where I was, and I wanted to guarantee a tab to land on with my eyes closed, I think I'd just do a rolling 1 2 2 combination. 1-5 is meditative for me, so I end up rolling through panes a lot while I'm processing my next action anyway 😂

And thank you for the amazing tool!

@stefanhaller
Copy link
Collaborator

Ah, I wasn't thinking about a timeout, but actually it may be a good solution to the problem. It could go like this:

  • if you are already in panel 2, and you hit 2:
    • if you are in a short time window (say, 300ms) after hitting 2, and that took you to panel 2 from a different panel, then go to the second tab
    • otherwise, simply go to the next tab, like ] does
  • otherwise, go to panel 2 and keep whatever tab is showing there

No configuration needed. It seems this should cover all cases, but shouldn't be surprising or annoying. Or am I missing something?

@riandrake
Copy link

Sorry for proposing a timeout, I think I made it more complex unnecessarily.

While I'd have a fast way to go to Remotes consistently with 2 2, I wouldn't have a fast way to go to Locals with just one press of 2. Instead, I'd have to press 2 2 2 2 to wrap around Tags, or wait for the timeout to pass before tapping 2 0-2 more times depending on the current panel.

I hadn't thoroughly considered what I thought should happen in the case where a sub-panel was already open, so I pulled up lazygit again to feel out what I'd expect the behaviour to be.

When pressing N (where N is 1-5):

  • If I'm not in Pane N, move to Pane N without changing its sub-panel (existing behaviour).
  • If I'm already in the Pane N, cycle through to the next sub-panel (new behaviour).

This seems okay without a timeout, no reset required, and so doesn't feel like a breaking change?

The additional feature that was missing that maybe led to the proposal of a reset: I noticed while testing is that the current sub-panel for an inactive panel is not immediately obvious. I couldn't see a color option for it either. I think if I could see that from a glance I'd feel less disoriented when switching panes.

Let me know if that's a separate feature request!

@stefanhaller
Copy link
Collaborator

OK, makes sense. I suppose we could start with that and see if this is good enough, and if not, we might add a config like gui.resetToFirstTabOnPanelJump or some such later.

I noticed while testing is that the current sub-panel for an inactive panel is not immediately obvious.

Hm, this might have something to do with your terminal's color scheme. It is quite obvious for me:
image

@jesseduffield
Copy link
Owner

I like that proposal, and for posterity, I do not like the idea of timeouts!

@stefanhaller
Copy link
Collaborator

Here's a draft PR so that we can try how it feels: #3794.

@werkz-by-drake
Copy link
Author

I like it!

Also as you suggested @stefanhaller it was just a terminal color issue - thank you.

The part I don't like is that while I'm nested inside into a tab (Remotes -> origin -> HEAD -> commit) and press the current pane's key (2), it currently pops all the way out and moves to the next pane.

I think it should either:

  • Pop back up to parent window (esc) until we've reached the top panel, before continuing pane swapping behavior
  • Do nothing

@stefanhaller
Copy link
Collaborator

The part I don't like is that while I'm nested inside into a tab (Remotes -> origin -> HEAD -> commit) and press the current pane's key (2), it currently pops all the way out and moves to the next pane.

Interesting, I actually like it this way. And it doesn't actually move to the next tab, but to the first one in that panel; but I happen to like that too, although it's probably unintentional. The same happens when you press ].

For me, the most common use case is that I'm looking at a remote branch to do a code review of a coworker's branch, and when I'm done I press [ to go back to my local branches. It's nice to know that 3 and ] work for that, too.

Actually I sometimes have the opposite wish: being taken out of nested views more often. An example is that I'm in panel 4, and go into a commit to look at its files; then I switch to panel 2, and when I come back to 4, I wish it would show me commits again. But that might be annoying in other cases, so I'm not proposing to change that.

@riandrake
Copy link

I see. If it's consistent with existing behavior, then I can't argue with that! 👍

@stefanhaller
Copy link
Collaborator

Fixed by #3794.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants