Skip to content

Improve display of "esc" keybinding in the keybindings status bar #4819

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

Merged
merged 11 commits into from
Aug 14, 2025

Conversation

stefanhaller
Copy link
Collaborator

@stefanhaller stefanhaller commented Aug 12, 2025

PR Description

  • For popup windows, the status bar would show Confirm: <enter> | Close/Cancel: <esc> | Cancel: <esc>. Omit the second <esc>.
  • Don't show the <esc> binding in other views when it doesn't do anything.
  • Change the text of the <esc> label to show what it does, based on context. This is very helpful because esc can cancel all sorts of things, and if several of these things are active at once, it is not obvious which one will be cancelled first.

Supersedes #4808.

Copy link

codacy-production bot commented Aug 12, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for d50e5851 97.39%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (d50e585) Report Missing Report Missing Report Missing
Head commit (da7121f) 57409 49910 86.94%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4819) 153 149 97.39%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@stefanhaller stefanhaller marked this pull request as draft August 12, 2025 15:17
@stefanhaller
Copy link
Collaborator Author

This is not ready for review yet, we can do a lot better still. Working on it.

@stefanhaller stefanhaller changed the title Avoid duplicate "esc" keybinding in keybindings status bar Improve display of "esc" keybinding in the keybindings status bar Aug 12, 2025
@stefanhaller stefanhaller force-pushed the avoid-duplicate-keybindings-in-options-map branch 2 times, most recently from 95e463c to cc235c6 Compare August 12, 2025 18:38
@stefanhaller
Copy link
Collaborator Author

@kyu08 This is ready for review now. If you have time to review this again (and/or test it a bit), that would be great, thanks!

@stefanhaller stefanhaller marked this pull request as ready for review August 12, 2025 18:40
@stefanhaller
Copy link
Collaborator Author

@kyu08 Does the thumb-up mean that you are going to review it, or that you did and think it's ok? That wasn't quite clear.

@kyu08
Copy link
Contributor

kyu08 commented Aug 14, 2025

Sorry for that unclear response.
I'll review it in few days.

@stefanhaller stefanhaller force-pushed the avoid-duplicate-keybindings-in-options-map branch from bc5d767 to 74ada8e Compare August 14, 2025 13:05
Copy link
Contributor

@kyu08 kyu08 left a comment

Choose a reason for hiding this comment

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

LGTM.
I read your changes and tried using this branch. This PR improves the UX of lazygit.

  • The context dependent descriptions for esc key improves ease of understanding(e.g. before: Cancel: <esc>, after: Abort rebase: <esc>).
    • It become clearer what would happen to press the key.
  • Also, I feel moving esc before ? is important change because sometimes width is not enough to show all keybindings as you said in fabe734.

Thanks for doing better work than my PR. 👏

@stefanhaller stefanhaller enabled auto-merge August 14, 2025 15:59
… view

It's maybe not totally obvious, so let's show it.

Esc now appears twice in the status bar, because the global controller also
appends its generic "Cancel". We'll fix this in the next commit.
Sometimes there is a local and a global keybinding for the same key; if both are
configured to be shown in the options map, we should only show the local one
because it takes precedence. This happens for example for <esc> in a popup, or
for <esc> in the focused main view.

Note that this is also a problem in the keybindings menu, and we don't solve
that here.
Cancelling searching (as opposed to filtering) is handled by gocui.
The code duplication between Escape and EscapeEnabled is unfortunate, but I
don't see a better way to solve this.
It is styled and includes a "(Reset)" button, so it's really not a
general-purpose description, but very specific to the Information view.
WHen several modes are active at the same time, it isn't totally obvious which
one will be cancelled first, so show this in the status bar.
The main reason for this is that sometimes the escape key is handled by a local
binding, in which case it appears before the '?' binding in the options status
bar, and other times it is handled by the global controller, in which case it
appeared after. Moving it to before the keybindings menu handler makes it appear
before '?' in both cases.

Also, if the window is too narrow to show all keybindings, the ones that don't
fit will be truncated, and in this case it is more important to show the esc
binding because of its context sensitivity.

This also moves the esc entry up a few positions in the keybindings menu, but I
don't think this matters much.
…view

Dismissing a range selection is handled by the global escape handler for all
list views, but not for the staging and patch building views, so we need to make
the esc description dynamic for these, too.
For many menus, just "Close" is fine, but some menus act more like confirmations
(e.g. the menu that appears when you cherry-pick and get conflicts); in this
case, it's good to make it more obvious that hitting esc cancels the whole
thing.
In some cases we set a disabled reason but leave the text empty, so that we
don't get an error toast when the item is invoked. In such a case it looks
awkward if there is a tooltip showing "Disabled: " with no following text.
@stefanhaller stefanhaller force-pushed the avoid-duplicate-keybindings-in-options-map branch from 74ada8e to da7121f Compare August 14, 2025 15:59
@stefanhaller stefanhaller merged commit 5b86716 into master Aug 14, 2025
13 checks passed
@stefanhaller stefanhaller deleted the avoid-duplicate-keybindings-in-options-map branch August 14, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants