Skip to content

Commit 5b86716

Browse files
authored
Improve display of "esc" keybinding in the keybindings status bar (#4819)
### 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.
2 parents d50e585 + da7121f commit 5b86716

21 files changed

+218
-53
lines changed

docs/keybindings/Keybindings_en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
2424
| `` R `` | Refresh | Refresh the git state (i.e. run `git status`, `git branch`, etc in background to update the contents of panels). This does not run `git fetch`. |
2525
| `` + `` | Next screen mode (normal/half/fullscreen) | |
2626
| `` _ `` | Prev screen mode | |
27+
| `` <esc> `` | Cancel | |
2728
| `` ? `` | Open keybindings menu | |
2829
| `` <c-s> `` | View filter options | View options for filtering the commit log, so that only commits matching the filter are shown. |
2930
| `` W `` | View diffing options | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3031
| `` <c-e> `` | View diffing options | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3132
| `` q `` | Quit | |
32-
| `` <esc> `` | Cancel | |
3333
| `` <c-w> `` | Toggle whitespace | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
3434
| `` z `` | Undo | The reflog will be used to determine what git command to run to undo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
3535
| `` <c-z> `` | Redo | The reflog will be used to determine what git command to run to redo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
@@ -256,7 +256,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
256256
| Key | Action | Info |
257257
|-----|--------|-------------|
258258
| `` <enter> `` | Execute | |
259-
| `` <esc> `` | Close | |
259+
| `` <esc> `` | Close/Cancel | |
260260
| `` / `` | Filter the current view by text | |
261261

262262
## Reflog

docs/keybindings/Keybindings_ja.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味
2424
| `` R `` | 更新 | Gitの状態を更新します(`git status``git branch`などをバックグラウンドで実行してパネルの内容を更新します)。これは`git fetch`を実行しません。 |
2525
| `` + `` | 次の画面モード(通常/半分/全画面) | |
2626
| `` _ `` | 前の画面モード | |
27+
| `` <esc> `` | キャンセル | |
2728
| `` ? `` | キーバインディングメニューを開く | |
2829
| `` <c-s> `` | フィルターオプションを表示 | コミットログのフィルタリングオプションを表示し、フィルタに一致するコミットのみを表示します。 |
2930
| `` W `` | 差分オプションを表示 | 2つのrefの差分に関連するオプションを表示します(例:選択したrefとの差分表示、差分を取るrefの入力、差分方向の反転など)。 |
3031
| `` <c-e> `` | 差分オプションを表示 | 2つのrefの差分に関連するオプションを表示します(例:選択したrefとの差分表示、差分を取るrefの入力、差分方向の反転など)。 |
3132
| `` q `` | 終了 | |
32-
| `` <esc> `` | キャンセル | |
3333
| `` <c-w> `` | 空白表示の切り替え | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
3434
| `` z `` | 元に戻す | 最後のgitコマンドを元に戻すために実行するgitコマンドを決定するためにreflogが使用されます。これにはワーキングツリーへの変更は含まれません。コミットのみが考慮されます。 |
3535
| `` <c-z> `` | やり直す | 最後のgitコマンドをやり直すために実行するgitコマンドを決定するためにreflogが使用されます。これにはワーキングツリーへの変更は含まれません。コミットのみが考慮されます。 |
@@ -302,7 +302,7 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味
302302
| Key | Action | Info |
303303
|-----|--------|-------------|
304304
| `` <enter> `` | 実行 | |
305-
| `` <esc> `` | 閉じる | |
305+
| `` <esc> `` | 閉じる/キャンセル | |
306306
| `` / `` | 現在のビューをテキストでフィルタリング | |
307307

308308
## リフログ

docs/keybindings/Keybindings_ko.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
2424
| `` R `` | 새로고침 | Refresh the git state (i.e. run `git status`, `git branch`, etc in background to update the contents of panels). This does not run `git fetch`. |
2525
| `` + `` | 다음 스크린 모드 (normal/half/fullscreen) | |
2626
| `` _ `` | 이전 스크린 모드 | |
27+
| `` <esc> `` | 취소 | |
2728
| `` ? `` | 매뉴 열기 | |
2829
| `` <c-s> `` | View filter-by-path options | View options for filtering the commit log, so that only commits matching the filter are shown. |
2930
| `` W `` | Diff 메뉴 열기 | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3031
| `` <c-e> `` | Diff 메뉴 열기 | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3132
| `` q `` | 종료 | |
32-
| `` <esc> `` | 취소 | |
3333
| `` <c-w> `` | 공백문자를 Diff 뷰에서 표시 여부 전환 | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
3434
| `` z `` | 되돌리기 (reflog) (실험적) | The reflog will be used to determine what git command to run to undo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
3535
| `` <c-z> `` | 다시 실행 (reflog) (실험적) | The reflog will be used to determine what git command to run to redo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
@@ -128,7 +128,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
128128
| Key | Action | Info |
129129
|-----|--------|-------------|
130130
| `` <enter> `` | 실행 | |
131-
| `` <esc> `` | 닫기 | |
131+
| `` <esc> `` | 닫기/취소 | |
132132
| `` / `` | Filter the current view by text | |
133133

134134
## 메인 패널 (Merging)

docs/keybindings/Keybindings_nl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
2424
| `` R `` | Verversen | Refresh the git state (i.e. run `git status`, `git branch`, etc in background to update the contents of panels). This does not run `git fetch`. |
2525
| `` + `` | Volgende scherm modus (normaal/half/groot) | |
2626
| `` _ `` | Vorige scherm modus | |
27+
| `` <esc> `` | Annuleren | |
2728
| `` ? `` | Open menu | |
2829
| `` <c-s> `` | Bekijk scoping opties | View options for filtering the commit log, so that only commits matching the filter are shown. |
2930
| `` W `` | Open diff menu | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3031
| `` <c-e> `` | Open diff menu | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3132
| `` q `` | Quit | |
32-
| `` <esc> `` | Annuleren | |
3333
| `` <c-w> `` | Toggle whitespace | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
3434
| `` z `` | Ongedaan maken (via reflog) (experimenteel) | The reflog will be used to determine what git command to run to undo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |
3535
| `` <c-z> `` | Redo (via reflog) (experimenteel) | The reflog will be used to determine what git command to run to redo the last git command. This does not include changes to the working tree; only commits are taken into consideration. |

docs/keybindings/Keybindings_pl.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ _Legenda: `<c-b>` oznacza ctrl+b, `<a-b>` oznacza alt+b, `B` oznacza shift+b_
2424
| `` R `` | Odśwież | Odśwież stan git (tj. uruchom `git status`, `git branch`, itp. w tle, aby zaktualizować zawartość paneli). To nie uruchamia `git fetch`. |
2525
| `` + `` | Następny tryb ekranu (normalny/półpełny/pełnoekranowy) | |
2626
| `` _ `` | Poprzedni tryb ekranu | |
27+
| `` <esc> `` | Anuluj | |
2728
| `` ? `` | Otwórz menu przypisań klawiszy | |
2829
| `` <c-s> `` | Pokaż opcje filtrowania | Pokaż opcje filtrowania dziennika commitów, tak aby pokazywane były tylko commity pasujące do filtra. |
2930
| `` W `` | Pokaż opcje różnicowania | Pokaż opcje dotyczące różnicowania dwóch refów, np. różnicowanie względem wybranego refa, wprowadzanie refa do różnicowania i odwracanie kierunku różnic. |
3031
| `` <c-e> `` | Pokaż opcje różnicowania | Pokaż opcje dotyczące różnicowania dwóch refów, np. różnicowanie względem wybranego refa, wprowadzanie refa do różnicowania i odwracanie kierunku różnic. |
3132
| `` q `` | Wyjdź | |
32-
| `` <esc> `` | Anuluj | |
3333
| `` <c-w> `` | Przełącz białe znaki | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
3434
| `` z `` | Cofnij | Dziennik reflog zostanie użyty do określenia, jakie polecenie git należy uruchomić, aby cofnąć ostatnie polecenie git. Nie obejmuje to zmian w drzewie roboczym; brane są pod uwagę tylko commity. |
3535
| `` <c-z> `` | Ponów | Dziennik reflog zostanie użyty do określenia, jakie polecenie git należy uruchomić, aby ponowić ostatnie polecenie git. Nie obejmuje to zmian w drzewie roboczym; brane są pod uwagę tylko commity. |
@@ -159,7 +159,7 @@ _Legenda: `<c-b>` oznacza ctrl+b, `<a-b>` oznacza alt+b, `B` oznacza shift+b_
159159
| Key | Action | Info |
160160
|-----|--------|-------------|
161161
| `` <enter> `` | Wykonaj | |
162-
| `` <esc> `` | Zamknij | |
162+
| `` <esc> `` | Zamknij/Anuluj | |
163163
| `` / `` | Filtruj bieżący widok po tekście | |
164164

165165
## Panel główny (normalny)

docs/keybindings/Keybindings_pt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
2424
| `` R `` | Atualizar | Atualize o estado do git (ou seja, execute `git status`, `git branch`, etc em segundo plano para atualizar o conteúdo de painéis). Isso não executa `git fetch`. |
2525
| `` + `` | Next screen mode (normal/half/fullscreen) | |
2626
| `` _ `` | Prev screen mode | |
27+
| `` <esc> `` | Cancelar | |
2728
| `` ? `` | Open keybindings menu | |
2829
| `` <c-s> `` | View filter options | View options for filtering the commit log, so that only commits matching the filter are shown. |
2930
| `` W `` | View diffing options | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3031
| `` <c-e> `` | View diffing options | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3132
| `` q `` | Sair | |
32-
| `` <esc> `` | Cancelar | |
3333
| `` <c-w> `` | Toggle whitespace | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
3434
| `` z `` | Desfazer | O reflog será usado para determinar qual comando git para executar para desfazer o último comando git. Isto não inclui mudanças na árvore de trabalho; apenas compromissos são tidos em consideração. |
3535
| `` <c-z> `` | Refazer | O reflog será usado para determinar qual comando git para executar para refazer o último comando git. Isto não inclui mudanças na árvore de trabalho; apenas compromissos são tidos em consideração. |
@@ -221,7 +221,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
221221
| Key | Action | Info |
222222
|-----|--------|-------------|
223223
| `` <enter> `` | Executar | |
224-
| `` <esc> `` | Fechar | |
224+
| `` <esc> `` | Fechar/Cancelar | |
225225
| `` / `` | Filter the current view by text | |
226226

227227
## Painel Principal (Normal)

docs/keybindings/Keybindings_ru.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ _Связки клавиш_
2424
| `` R `` | Обновить | Refresh the git state (i.e. run `git status`, `git branch`, etc in background to update the contents of panels). This does not run `git fetch`. |
2525
| `` + `` | Следующий режим экрана (нормальный/полуэкранный/полноэкранный) | |
2626
| `` _ `` | Предыдущий режим экрана | |
27+
| `` <esc> `` | Отменить | |
2728
| `` ? `` | Открыть меню | |
2829
| `` <c-s> `` | Просмотреть параметры фильтрации по пути | View options for filtering the commit log, so that only commits matching the filter are shown. |
2930
| `` W `` | Открыть меню сравнении | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3031
| `` <c-e> `` | Открыть меню сравнении | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3132
| `` q `` | Выйти | |
32-
| `` <esc> `` | Отменить | |
3333
| `` <c-w> `` | Переключить отображение изменении пробелов в просмотрщике сравнении | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
3434
| `` z `` | Отменить (через reflog) (экспериментальный) | Журнал ссылок (reflog) будет использоваться для определения того, какую команду git запустить, чтобы отменить последнюю команду git. Сюда не входят изменения в рабочем дереве; учитываются только коммиты. |
3535
| `` <c-z> `` | Повторить (через reflog) (экспериментальный) | Журнал ссылок (reflog) будет использоваться для определения того, какую команду git нужно запустить, чтобы повторить последнюю команду git. Сюда не входят изменения в рабочем дереве; учитываются только коммиты. |
@@ -227,7 +227,7 @@ _Связки клавиш_
227227
| Key | Action | Info |
228228
|-----|--------|-------------|
229229
| `` <enter> `` | Выполнить | |
230-
| `` <esc> `` | Закрыть | |
230+
| `` <esc> `` | Закрыть/отменить | |
231231
| `` / `` | Filter the current view by text | |
232232

233233
## Панель Подтверждения

docs/keybindings/Keybindings_zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ _图例:`<c-b>` 意味着ctrl+b, `<a-b>意味着Alt+b, `B` 意味着shift+b_
2424
| `` R `` | 刷新 | 刷新git状态(即在后台上运行`git status`,`git branch`等命令以更新面板内容) 不会运行`git fetch` |
2525
| `` + `` | 下一屏模式(正常/半屏/全屏) | |
2626
| `` _ `` | 上一屏模式 | |
27+
| `` <esc> `` | 取消 | |
2728
| `` ? `` | 打开菜单 | |
2829
| `` <c-s> `` | 查看按路径过滤选项 | 查看用于过滤提交日志的选项,以便仅显示与过滤器匹配的提交。 |
2930
| `` W `` | 打开 diff 菜单 | 查看与比较两个引用相关的选项,例如与选定的 ref 进行比较,输入要比较的 ref,然后反转比较方向。 |
3031
| `` <c-e> `` | 打开 diff 菜单 | 查看与比较两个引用相关的选项,例如与选定的 ref 进行比较,输入要比较的 ref,然后反转比较方向。 |
3132
| `` q `` | 退出 | |
32-
| `` <esc> `` | 取消 | |
3333
| `` <c-w> `` | 切换是否在差异视图中显示空白字符差异 | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
3434
| `` z `` | 撤销 | Reflog将用于确定运行哪个git命令来撤消最后一个git命令。这并不包括对工作树的更改,只考虑提交。 |
3535
| `` <c-z> `` | 重做 | Reflog将用于确定运行哪个git命令来重做上一个git命令。这并不包括对工作树的更改,只考虑提交。 |

docs/keybindings/Keybindings_zh-TW.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ _說明:`<c-b>` 表示 Ctrl+B、`<a-b>` 表示 Alt+B,`B`表示 Shift+B
2424
| `` R `` | 重新整理 | Refresh the git state (i.e. run `git status`, `git branch`, etc in background to update the contents of panels). This does not run `git fetch`. |
2525
| `` + `` | 下一個螢幕模式(常規/半螢幕/全螢幕) | |
2626
| `` _ `` | 上一個螢幕模式 | |
27+
| `` <esc> `` | 取消 | |
2728
| `` ? `` | 開啟選單 | |
2829
| `` <c-s> `` | 檢視篩選路徑選項 | View options for filtering the commit log, so that only commits matching the filter are shown. |
2930
| `` W `` | 開啟差異比較選單 | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3031
| `` <c-e> `` | 開啟差異比較選單 | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. |
3132
| `` q `` | 結束 | |
32-
| `` <esc> `` | 取消 | |
3333
| `` <c-w> `` | 切換是否在差異檢視中顯示空格變更 | Toggle whether or not whitespace changes are shown in the diff view.<br><br>The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. |
3434
| `` z `` | 復原 | 將使用 reflog 確任 git 指令以復原。這不包括工作區更改;只考慮提交。 |
3535
| `` <c-z> `` | 取消復原 | 將使用 reflog 確任 git 指令以重作。這不包括工作區更改;只考慮提交。 |
@@ -119,7 +119,7 @@ _說明:`<c-b>` 表示 Ctrl+B、`<a-b>` 表示 Alt+B,`B`表示 Shift+B
119119
| Key | Action | Info |
120120
|-----|--------|-------------|
121121
| `` <enter> `` | 執行 | |
122-
| `` <esc> `` | 關閉 | |
122+
| `` <esc> `` | 關閉/取消 | |
123123
| `` / `` | 搜尋 | |
124124

125125
## 子提交

pkg/gui/controllers/global_controller.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type
5858
Handler: opts.Guards.NoPopupPanel(self.prevScreenMode),
5959
Description: self.c.Tr.PrevScreenMode,
6060
},
61+
{
62+
Key: opts.GetKey(opts.Config.Universal.Return),
63+
Modifier: gocui.ModNone,
64+
Handler: self.escape,
65+
Description: self.c.Tr.Cancel,
66+
DescriptionFunc: self.escapeDescription,
67+
GetDisabledReason: self.escapeEnabled,
68+
DisplayOnScreen: true,
69+
},
6170
{
6271
ViewName: "",
6372
Key: opts.GetKey(opts.Config.Universal.OptionMenu),
@@ -114,13 +123,6 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type
114123
Modifier: gocui.ModNone,
115124
Handler: self.quitWithoutChangingDirectory,
116125
},
117-
{
118-
Key: opts.GetKey(opts.Config.Universal.Return),
119-
Modifier: gocui.ModNone,
120-
Handler: self.escape,
121-
Description: self.c.Tr.Cancel,
122-
DisplayOnScreen: true,
123-
},
124126
{
125127
Key: opts.GetKey(opts.Config.Universal.ToggleWhitespaceInDiffView),
126128
Handler: self.toggleWhitespace,
@@ -190,6 +192,20 @@ func (self *GlobalController) escape() error {
190192
return (&QuitActions{c: self.c}).Escape()
191193
}
192194

195+
func (self *GlobalController) escapeDescription() string {
196+
return (&QuitActions{c: self.c}).EscapeDescription()
197+
}
198+
199+
func (self *GlobalController) escapeEnabled() *types.DisabledReason {
200+
if (&QuitActions{c: self.c}).EscapeEnabled() {
201+
return nil
202+
}
203+
204+
// The empty error text is intentional. We don't want to show an error
205+
// toast for this, but only hide it from the options map.
206+
return &types.DisabledReason{Text: ""}
207+
}
208+
193209
func (self *GlobalController) toggleWhitespace() error {
194210
return (&ToggleWhitespaceAction{c: self.c}).Call()
195211
}

0 commit comments

Comments
 (0)