diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index ab1a8684268..b73a505c3a8 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -24,12 +24,12 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` 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`. | | `` + `` | Next screen mode (normal/half/fullscreen) | | | `` _ `` | Prev screen mode | | +| `` `` | Cancel | | | `` ? `` | Open keybindings menu | | | `` `` | View filter options | View options for filtering the commit log, so that only commits matching the filter are shown. | | `` 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. | | `` `` | 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. | | `` q `` | Quit | | -| `` `` | Cancel | | | `` `` | Toggle whitespace | Toggle whether or not whitespace changes are shown in the diff view.

The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. | | `` 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. | | `` `` | 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: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | Key | Action | Info | |-----|--------|-------------| | `` `` | Execute | | -| `` `` | Close | | +| `` `` | Close/Cancel | | | `` / `` | Filter the current view by text | | ## Reflog diff --git a/docs/keybindings/Keybindings_ja.md b/docs/keybindings/Keybindings_ja.md index ec536b302f3..9d8460d964c 100644 --- a/docs/keybindings/Keybindings_ja.md +++ b/docs/keybindings/Keybindings_ja.md @@ -24,12 +24,12 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味 | `` R `` | 更新 | Gitの状態を更新します(`git status`、`git branch`などをバックグラウンドで実行してパネルの内容を更新します)。これは`git fetch`を実行しません。 | | `` + `` | 次の画面モード(通常/半分/全画面) | | | `` _ `` | 前の画面モード | | +| `` `` | キャンセル | | | `` ? `` | キーバインディングメニューを開く | | | `` `` | フィルターオプションを表示 | コミットログのフィルタリングオプションを表示し、フィルタに一致するコミットのみを表示します。 | | `` W `` | 差分オプションを表示 | 2つのrefの差分に関連するオプションを表示します(例:選択したrefとの差分表示、差分を取るrefの入力、差分方向の反転など)。 | | `` `` | 差分オプションを表示 | 2つのrefの差分に関連するオプションを表示します(例:選択したrefとの差分表示、差分を取るrefの入力、差分方向の反転など)。 | | `` q `` | 終了 | | -| `` `` | キャンセル | | | `` `` | 空白表示の切り替え | Toggle whether or not whitespace changes are shown in the diff view.

The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. | | `` z `` | 元に戻す | 最後のgitコマンドを元に戻すために実行するgitコマンドを決定するためにreflogが使用されます。これにはワーキングツリーへの変更は含まれません。コミットのみが考慮されます。 | | `` `` | やり直す | 最後のgitコマンドをやり直すために実行するgitコマンドを決定するためにreflogが使用されます。これにはワーキングツリーへの変更は含まれません。コミットのみが考慮されます。 | @@ -302,7 +302,7 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味 | Key | Action | Info | |-----|--------|-------------| | `` `` | 実行 | | -| `` `` | 閉じる | | +| `` `` | 閉じる/キャンセル | | | `` / `` | 現在のビューをテキストでフィルタリング | | ## リフログ diff --git a/docs/keybindings/Keybindings_ko.md b/docs/keybindings/Keybindings_ko.md index de2c6c71964..1dd33ba5495 100644 --- a/docs/keybindings/Keybindings_ko.md +++ b/docs/keybindings/Keybindings_ko.md @@ -24,12 +24,12 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` 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`. | | `` + `` | 다음 스크린 모드 (normal/half/fullscreen) | | | `` _ `` | 이전 스크린 모드 | | +| `` `` | 취소 | | | `` ? `` | 매뉴 열기 | | | `` `` | View filter-by-path options | View options for filtering the commit log, so that only commits matching the filter are shown. | | `` 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. | | `` `` | Diff 메뉴 열기 | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. | | `` q `` | 종료 | | -| `` `` | 취소 | | | `` `` | 공백문자를 Diff 뷰에서 표시 여부 전환 | Toggle whether or not whitespace changes are shown in the diff view.

The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. | | `` 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. | | `` `` | 다시 실행 (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: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | Key | Action | Info | |-----|--------|-------------| | `` `` | 실행 | | -| `` `` | 닫기 | | +| `` `` | 닫기/취소 | | | `` / `` | Filter the current view by text | | ## 메인 패널 (Merging) diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index cda93faee6d..658e69772aa 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -24,12 +24,12 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` 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`. | | `` + `` | Volgende scherm modus (normaal/half/groot) | | | `` _ `` | Vorige scherm modus | | +| `` `` | Annuleren | | | `` ? `` | Open menu | | | `` `` | Bekijk scoping opties | View options for filtering the commit log, so that only commits matching the filter are shown. | | `` 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. | | `` `` | 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. | | `` q `` | Quit | | -| `` `` | Annuleren | | | `` `` | Toggle whitespace | Toggle whether or not whitespace changes are shown in the diff view.

The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. | | `` 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. | | `` `` | 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. | diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 311194a0f76..f599d6cff9d 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -24,12 +24,12 @@ _Legenda: `` oznacza ctrl+b, `` oznacza alt+b, `B` oznacza shift+b_ | `` 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`. | | `` + `` | Następny tryb ekranu (normalny/półpełny/pełnoekranowy) | | | `` _ `` | Poprzedni tryb ekranu | | +| `` `` | Anuluj | | | `` ? `` | Otwórz menu przypisań klawiszy | | | `` `` | Pokaż opcje filtrowania | Pokaż opcje filtrowania dziennika commitów, tak aby pokazywane były tylko commity pasujące do filtra. | | `` 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. | | `` `` | 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. | | `` q `` | Wyjdź | | -| `` `` | Anuluj | | | `` `` | Przełącz białe znaki | Toggle whether or not whitespace changes are shown in the diff view.

The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. | | `` 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. | | `` `` | 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: `` oznacza ctrl+b, `` oznacza alt+b, `B` oznacza shift+b_ | Key | Action | Info | |-----|--------|-------------| | `` `` | Wykonaj | | -| `` `` | Zamknij | | +| `` `` | Zamknij/Anuluj | | | `` / `` | Filtruj bieżący widok po tekście | | ## Panel główny (normalny) diff --git a/docs/keybindings/Keybindings_pt.md b/docs/keybindings/Keybindings_pt.md index 096be874dc1..66c92a90e6c 100644 --- a/docs/keybindings/Keybindings_pt.md +++ b/docs/keybindings/Keybindings_pt.md @@ -24,12 +24,12 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` 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`. | | `` + `` | Next screen mode (normal/half/fullscreen) | | | `` _ `` | Prev screen mode | | +| `` `` | Cancelar | | | `` ? `` | Open keybindings menu | | | `` `` | View filter options | View options for filtering the commit log, so that only commits matching the filter are shown. | | `` 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. | | `` `` | 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. | | `` q `` | Sair | | -| `` `` | Cancelar | | | `` `` | Toggle whitespace | Toggle whether or not whitespace changes are shown in the diff view.

The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. | | `` 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. | | `` `` | 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: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | Key | Action | Info | |-----|--------|-------------| | `` `` | Executar | | -| `` `` | Fechar | | +| `` `` | Fechar/Cancelar | | | `` / `` | Filter the current view by text | | ## Painel Principal (Normal) diff --git a/docs/keybindings/Keybindings_ru.md b/docs/keybindings/Keybindings_ru.md index 48af4b35f76..efd8a34bf74 100644 --- a/docs/keybindings/Keybindings_ru.md +++ b/docs/keybindings/Keybindings_ru.md @@ -24,12 +24,12 @@ _Связки клавиш_ | `` 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`. | | `` + `` | Следующий режим экрана (нормальный/полуэкранный/полноэкранный) | | | `` _ `` | Предыдущий режим экрана | | +| `` `` | Отменить | | | `` ? `` | Открыть меню | | | `` `` | Просмотреть параметры фильтрации по пути | View options for filtering the commit log, so that only commits matching the filter are shown. | | `` W `` | Открыть меню сравнении | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. | | `` `` | Открыть меню сравнении | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. | | `` q `` | Выйти | | -| `` `` | Отменить | | | `` `` | Переключить отображение изменении пробелов в просмотрщике сравнении | Toggle whether or not whitespace changes are shown in the diff view.

The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. | | `` z `` | Отменить (через reflog) (экспериментальный) | Журнал ссылок (reflog) будет использоваться для определения того, какую команду git запустить, чтобы отменить последнюю команду git. Сюда не входят изменения в рабочем дереве; учитываются только коммиты. | | `` `` | Повторить (через reflog) (экспериментальный) | Журнал ссылок (reflog) будет использоваться для определения того, какую команду git нужно запустить, чтобы повторить последнюю команду git. Сюда не входят изменения в рабочем дереве; учитываются только коммиты. | @@ -227,7 +227,7 @@ _Связки клавиш_ | Key | Action | Info | |-----|--------|-------------| | `` `` | Выполнить | | -| `` `` | Закрыть | | +| `` `` | Закрыть/отменить | | | `` / `` | Filter the current view by text | | ## Панель Подтверждения diff --git a/docs/keybindings/Keybindings_zh-CN.md b/docs/keybindings/Keybindings_zh-CN.md index c85be039b2f..26f7cc4a243 100644 --- a/docs/keybindings/Keybindings_zh-CN.md +++ b/docs/keybindings/Keybindings_zh-CN.md @@ -24,12 +24,12 @@ _图例:`` 意味着ctrl+b, `意味着Alt+b, `B` 意味着shift+b_ | `` R `` | 刷新 | 刷新git状态(即在后台上运行`git status`,`git branch`等命令以更新面板内容) 不会运行`git fetch` | | `` + `` | 下一屏模式(正常/半屏/全屏) | | | `` _ `` | 上一屏模式 | | +| `` `` | 取消 | | | `` ? `` | 打开菜单 | | | `` `` | 查看按路径过滤选项 | 查看用于过滤提交日志的选项,以便仅显示与过滤器匹配的提交。 | | `` W `` | 打开 diff 菜单 | 查看与比较两个引用相关的选项,例如与选定的 ref 进行比较,输入要比较的 ref,然后反转比较方向。 | | `` `` | 打开 diff 菜单 | 查看与比较两个引用相关的选项,例如与选定的 ref 进行比较,输入要比较的 ref,然后反转比较方向。 | | `` q `` | 退出 | | -| `` `` | 取消 | | | `` `` | 切换是否在差异视图中显示空白字符差异 | Toggle whether or not whitespace changes are shown in the diff view.

The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. | | `` z `` | 撤销 | Reflog将用于确定运行哪个git命令来撤消最后一个git命令。这并不包括对工作树的更改,只考虑提交。 | | `` `` | 重做 | Reflog将用于确定运行哪个git命令来重做上一个git命令。这并不包括对工作树的更改,只考虑提交。 | diff --git a/docs/keybindings/Keybindings_zh-TW.md b/docs/keybindings/Keybindings_zh-TW.md index 5f980089ba6..a716e6cfdc1 100644 --- a/docs/keybindings/Keybindings_zh-TW.md +++ b/docs/keybindings/Keybindings_zh-TW.md @@ -24,12 +24,12 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B | `` 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`. | | `` + `` | 下一個螢幕模式(常規/半螢幕/全螢幕) | | | `` _ `` | 上一個螢幕模式 | | +| `` `` | 取消 | | | `` ? `` | 開啟選單 | | | `` `` | 檢視篩選路徑選項 | View options for filtering the commit log, so that only commits matching the filter are shown. | | `` W `` | 開啟差異比較選單 | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. | | `` `` | 開啟差異比較選單 | View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction. | | `` q `` | 結束 | | -| `` `` | 取消 | | | `` `` | 切換是否在差異檢視中顯示空格變更 | Toggle whether or not whitespace changes are shown in the diff view.

The default can be changed in the config file with the key 'git.ignoreWhitespaceInDiffView'. | | `` z `` | 復原 | 將使用 reflog 確任 git 指令以復原。這不包括工作區更改;只考慮提交。 | | `` `` | 取消復原 | 將使用 reflog 確任 git 指令以重作。這不包括工作區更改;只考慮提交。 | @@ -119,7 +119,7 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B | Key | Action | Info | |-----|--------|-------------| | `` `` | 執行 | | -| `` `` | 關閉 | | +| `` `` | 關閉/取消 | | | `` / `` | 搜尋 | | ## 子提交 diff --git a/pkg/gui/controllers/global_controller.go b/pkg/gui/controllers/global_controller.go index 9dfbeb4546f..fcf281cf4d1 100644 --- a/pkg/gui/controllers/global_controller.go +++ b/pkg/gui/controllers/global_controller.go @@ -58,6 +58,15 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type Handler: opts.Guards.NoPopupPanel(self.prevScreenMode), Description: self.c.Tr.PrevScreenMode, }, + { + Key: opts.GetKey(opts.Config.Universal.Return), + Modifier: gocui.ModNone, + Handler: self.escape, + Description: self.c.Tr.Cancel, + DescriptionFunc: self.escapeDescription, + GetDisabledReason: self.escapeEnabled, + DisplayOnScreen: true, + }, { ViewName: "", Key: opts.GetKey(opts.Config.Universal.OptionMenu), @@ -114,13 +123,6 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type Modifier: gocui.ModNone, Handler: self.quitWithoutChangingDirectory, }, - { - Key: opts.GetKey(opts.Config.Universal.Return), - Modifier: gocui.ModNone, - Handler: self.escape, - Description: self.c.Tr.Cancel, - DisplayOnScreen: true, - }, { Key: opts.GetKey(opts.Config.Universal.ToggleWhitespaceInDiffView), Handler: self.toggleWhitespace, @@ -190,6 +192,20 @@ func (self *GlobalController) escape() error { return (&QuitActions{c: self.c}).Escape() } +func (self *GlobalController) escapeDescription() string { + return (&QuitActions{c: self.c}).EscapeDescription() +} + +func (self *GlobalController) escapeEnabled() *types.DisabledReason { + if (&QuitActions{c: self.c}).EscapeEnabled() { + return nil + } + + // The empty error text is intentional. We don't want to show an error + // toast for this, but only hide it from the options map. + return &types.DisabledReason{Text: ""} +} + func (self *GlobalController) toggleWhitespace() error { return (&ToggleWhitespaceAction{c: self.c}).Call() } diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go index df059bef48e..c5927527553 100644 --- a/pkg/gui/controllers/helpers/confirmation_helper.go +++ b/pkg/gui/controllers/helpers/confirmation_helper.go @@ -348,7 +348,7 @@ func (self *ConfirmationHelper) IsPopupPanelFocused() bool { func (self *ConfirmationHelper) TooltipForMenuItem(menuItem *types.MenuItem) string { tooltip := menuItem.Tooltip - if menuItem.DisabledReason != nil { + if menuItem.DisabledReason != nil && menuItem.DisabledReason.Text != "" { if tooltip != "" { tooltip += "\n\n" } diff --git a/pkg/gui/controllers/helpers/mode_helper.go b/pkg/gui/controllers/helpers/mode_helper.go index 702825c5889..e44d7b01bcd 100644 --- a/pkg/gui/controllers/helpers/mode_helper.go +++ b/pkg/gui/controllers/helpers/mode_helper.go @@ -40,7 +40,8 @@ func NewModeHelper( type ModeStatus struct { IsActive func() bool - Description func() string + InfoLabel func() string + CancelLabel func() string Reset func() error } @@ -48,7 +49,7 @@ func (self *ModeHelper) Statuses() []ModeStatus { return []ModeStatus{ { IsActive: self.c.Modes().Diffing.Active, - Description: func() string { + InfoLabel: func() string { return self.withResetButton( fmt.Sprintf( "%s %s", @@ -58,18 +59,24 @@ func (self *ModeHelper) Statuses() []ModeStatus { style.FgMagenta, ) }, + CancelLabel: func() string { + return self.c.Tr.CancelDiffingMode + }, Reset: self.diffHelper.ExitDiffMode, }, { IsActive: self.c.Git().Patch.PatchBuilder.Active, - Description: func() string { + InfoLabel: func() string { return self.withResetButton(self.c.Tr.BuildingPatch, style.FgYellow.SetBold()) }, + CancelLabel: func() string { + return self.c.Tr.ExitCustomPatchBuilder + }, Reset: self.patchBuildingHelper.Reset, }, { IsActive: self.c.Modes().Filtering.Active, - Description: func() string { + InfoLabel: func() string { filterContent := lo.Ternary(self.c.Modes().Filtering.GetPath() != "", self.c.Modes().Filtering.GetPath(), self.c.Modes().Filtering.GetAuthor()) return self.withResetButton( fmt.Sprintf( @@ -80,21 +87,27 @@ func (self *ModeHelper) Statuses() []ModeStatus { style.FgRed, ) }, + CancelLabel: func() string { + return self.c.Tr.ExitFilterMode + }, Reset: self.ExitFilterMode, }, { IsActive: self.c.Modes().MarkedBaseCommit.Active, - Description: func() string { + InfoLabel: func() string { return self.withResetButton( self.c.Tr.MarkedBaseCommitStatus, style.FgCyan, ) }, + CancelLabel: func() string { + return self.c.Tr.CancelMarkedBaseCommit + }, Reset: self.mergeAndRebaseHelper.ResetMarkedBaseCommit, }, { IsActive: self.c.Modes().CherryPicking.Active, - Description: func() string { + InfoLabel: func() string { copiedCount := len(self.c.Modes().CherryPicking.CherryPickedCommits) text := self.c.Tr.CommitsCopied if copiedCount == 1 { @@ -110,27 +123,36 @@ func (self *ModeHelper) Statuses() []ModeStatus { style.FgCyan, ) }, + CancelLabel: func() string { + return self.c.Tr.ResetCherryPickShort + }, Reset: self.cherryPickHelper.Reset, }, { IsActive: func() bool { return !self.suppressRebasingMode && self.c.Git().Status.WorkingTreeState().Any() }, - Description: func() string { + InfoLabel: func() string { workingTreeState := self.c.Git().Status.WorkingTreeState() return self.withResetButton( workingTreeState.Title(self.c.Tr), style.FgYellow, ) }, + CancelLabel: func() string { + return fmt.Sprintf(self.c.Tr.AbortTitle, self.c.Git().Status.WorkingTreeState().CommandName()) + }, Reset: self.mergeAndRebaseHelper.AbortMergeOrRebaseWithConfirm, }, { IsActive: func() bool { return self.c.Model().BisectInfo.Started() }, - Description: func() string { + InfoLabel: func() string { return self.withResetButton(self.c.Tr.Bisect.Bisecting, style.FgGreen) }, + CancelLabel: func() string { + return self.c.Tr.Actions.ResetBisect + }, Reset: self.bisectHelper.Reset, }, } diff --git a/pkg/gui/controllers/main_view_controller.go b/pkg/gui/controllers/main_view_controller.go index 5dfdb3233ac..fa7e6438a2e 100644 --- a/pkg/gui/controllers/main_view_controller.go +++ b/pkg/gui/controllers/main_view_controller.go @@ -39,9 +39,10 @@ func (self *MainViewController) GetKeybindings(opts types.KeybindingsOpts) []*ty DisplayOnScreen: true, }, { - Key: opts.GetKey(opts.Config.Universal.Return), - Handler: self.escape, - Description: self.c.Tr.ExitFocusedMainView, + Key: opts.GetKey(opts.Config.Universal.Return), + Handler: self.escape, + Description: self.c.Tr.ExitFocusedMainView, + DisplayOnScreen: true, }, { // overriding this because we want to read all of the task's output before we start searching diff --git a/pkg/gui/controllers/menu_controller.go b/pkg/gui/controllers/menu_controller.go index 8baf9104ea3..25d919f542e 100644 --- a/pkg/gui/controllers/menu_controller.go +++ b/pkg/gui/controllers/menu_controller.go @@ -47,7 +47,7 @@ func (self *MenuController) GetKeybindings(opts types.KeybindingsOpts) []*types. { Key: opts.GetKey(opts.Config.Universal.Return), Handler: self.close, - Description: self.c.Tr.Close, + Description: self.c.Tr.CloseCancel, DisplayOnScreen: true, }, } diff --git a/pkg/gui/controllers/patch_building_controller.go b/pkg/gui/controllers/patch_building_controller.go index 166cc4a2b31..c4f8390f6e8 100644 --- a/pkg/gui/controllers/patch_building_controller.go +++ b/pkg/gui/controllers/patch_building_controller.go @@ -43,9 +43,11 @@ func (self *PatchBuildingController) GetKeybindings(opts types.KeybindingsOpts) DisplayOnScreen: true, }, { - Key: opts.GetKey(opts.Config.Universal.Return), - Handler: self.Escape, - Description: self.c.Tr.ExitCustomPatchBuilder, + Key: opts.GetKey(opts.Config.Universal.Return), + Handler: self.Escape, + Description: self.c.Tr.ExitCustomPatchBuilder, + DescriptionFunc: self.EscapeDescription, + DisplayOnScreen: true, }, } } @@ -179,3 +181,18 @@ func (self *PatchBuildingController) Escape() error { self.c.Helpers().PatchBuilding.Escape() return nil } + +func (self *PatchBuildingController) EscapeDescription() string { + context := self.c.Contexts().CustomPatchBuilder + if state := context.GetState(); state != nil { + if state.SelectingRange() { + return self.c.Tr.DismissRangeSelect + } + + if state.SelectingHunkEnabledByUser() { + return self.c.Tr.SelectLineByLine + } + } + + return self.c.Tr.ExitCustomPatchBuilder +} diff --git a/pkg/gui/controllers/quit_actions.go b/pkg/gui/controllers/quit_actions.go index 2775a92a679..4713a6e23b6 100644 --- a/pkg/gui/controllers/quit_actions.go +++ b/pkg/gui/controllers/quit_actions.go @@ -48,6 +48,8 @@ func (self *QuitActions) confirmQuitDuringUpdate() error { } func (self *QuitActions) Escape() error { + // If you make changes to this function, be sure to update EscapeEnabled and EscapeDescription accordingly. + currentContext := self.c.Context().Current() if listContext, ok := currentContext.(types.IListContext); ok { @@ -58,17 +60,12 @@ func (self *QuitActions) Escape() error { } } - switch ctx := currentContext.(type) { - case types.IFilterableContext: + // Cancelling searching (as opposed to filtering) is handled by gocui + if ctx, ok := currentContext.(types.IFilterableContext); ok { if ctx.IsFiltering() { self.c.Helpers().Search.Cancel() return nil } - case types.ISearchableContext: - if ctx.IsSearching() { - self.c.Helpers().Search.Cancel() - return nil - } } parentContext := currentContext.GetParentContext() @@ -95,3 +92,79 @@ func (self *QuitActions) Escape() error { return nil } + +func (self *QuitActions) EscapeEnabled() bool { + currentContext := self.c.Context().Current() + + if listContext, ok := currentContext.(types.IListContext); ok { + if listContext.GetList().IsSelectingRange() { + return true + } + } + + if ctx, ok := currentContext.(types.IFilterableContext); ok { + if ctx.IsFiltering() { + return true + } + } + + parentContext := currentContext.GetParentContext() + if parentContext != nil { + return true + } + + for _, mode := range self.c.Helpers().Mode.Statuses() { + if mode.IsActive() { + return true + } + } + + repoPathStack := self.c.State().GetRepoPathStack() + if !repoPathStack.IsEmpty() { + return true + } + + if self.c.UserConfig().QuitOnTopLevelReturn { + return true + } + + return false +} + +func (self *QuitActions) EscapeDescription() string { + currentContext := self.c.Context().Current() + + if listContext, ok := currentContext.(types.IListContext); ok { + if listContext.GetList().IsSelectingRange() { + return self.c.Tr.DismissRangeSelect + } + } + + if ctx, ok := currentContext.(types.IFilterableContext); ok { + if ctx.IsFiltering() { + return self.c.Tr.ExitFilterMode + } + } + + parentContext := currentContext.GetParentContext() + if parentContext != nil { + return self.c.Tr.ExitSubview + } + + for _, mode := range self.c.Helpers().Mode.Statuses() { + if mode.IsActive() { + return mode.CancelLabel() + } + } + + repoPathStack := self.c.State().GetRepoPathStack() + if !repoPathStack.IsEmpty() { + return self.c.Tr.BackToParentRepo + } + + if self.c.UserConfig().QuitOnTopLevelReturn { + return self.c.Tr.Quit + } + + return self.c.Tr.Cancel +} diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index 51c6fafec0e..f667dd212c3 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -68,9 +68,11 @@ func (self *StagingController) GetKeybindings(opts types.KeybindingsOpts) []*typ Tooltip: self.c.Tr.EditFileTooltip, }, { - Key: opts.GetKey(opts.Config.Universal.Return), - Handler: self.Escape, - Description: self.c.Tr.ReturnToFilesPanel, + Key: opts.GetKey(opts.Config.Universal.Return), + Handler: self.Escape, + Description: self.c.Tr.ReturnToFilesPanel, + DescriptionFunc: self.EscapeDescription, + DisplayOnScreen: true, }, { Key: opts.GetKey(opts.Config.Universal.TogglePanel), @@ -178,6 +180,20 @@ func (self *StagingController) Escape() error { return nil } +func (self *StagingController) EscapeDescription() string { + if state := self.context.GetState(); state != nil { + if state.SelectingRange() { + return self.c.Tr.DismissRangeSelect + } + + if state.SelectingHunkEnabledByUser() { + return self.c.Tr.SelectLineByLine + } + } + + return self.c.Tr.ReturnToFilesPanel +} + func (self *StagingController) TogglePanel() error { if self.otherContext.GetState() != nil { self.c.Context().Push(self.otherContext, types.OnFocusOpts{}) diff --git a/pkg/gui/information_panel.go b/pkg/gui/information_panel.go index ab2f3512d25..76001ecea06 100644 --- a/pkg/gui/information_panel.go +++ b/pkg/gui/information_panel.go @@ -10,7 +10,7 @@ import ( func (gui *Gui) informationStr() string { if activeMode, ok := gui.helpers.Mode.GetActiveMode(); ok { - return activeMode.Description() + return activeMode.InfoLabel() } if gui.g.Mouse { diff --git a/pkg/gui/options_map.go b/pkg/gui/options_map.go index bacc3b1069b..45521546883 100644 --- a/pkg/gui/options_map.go +++ b/pkg/gui/options_map.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + "github.com/jesseduffield/generics/set" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" @@ -38,7 +39,14 @@ func (self *OptionsMapMgr) renderContextOptionsMap() { currentContextBindings := currentContext.GetKeybindings(self.c.KeybindingsOpts()) globalBindings := self.c.Contexts().Global.GetKeybindings(self.c.KeybindingsOpts()) - allBindings := append(currentContextBindings, globalBindings...) + currentContextKeys := set.NewFromSlice( + lo.Map(currentContextBindings, func(binding *types.Binding, _ int) types.Key { + return binding.Key + })) + + allBindings := append(currentContextBindings, lo.Filter(globalBindings, func(b *types.Binding, _ int) bool { + return !currentContextKeys.Includes(b.Key) + })...) bindingsToDisplay := lo.Filter(allBindings, func(binding *types.Binding, _ int) bool { return binding.DisplayOnScreen && !binding.IsDisabled() diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 39227d25d07..faedeb6e54c 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -601,6 +601,7 @@ type TranslationSet struct { RenameBranchWarning string OpenKeybindingsMenu string ResetCherryPick string + ResetCherryPickShort string NextTab string PrevTab string CantUndoWhileRebasing string @@ -634,6 +635,7 @@ type TranslationSet struct { SwapDiff string ViewDiffingOptions string ViewDiffingOptionsTooltip string + CancelDiffingMode string OpenCommandLogMenu string OpenCommandLogMenuTooltip string ShowingGitDiff string @@ -671,6 +673,7 @@ type TranslationSet struct { SubmoduleStashAndReset string AndResetSubmodules string EnterSubmoduleTooltip string + BackToParentRepo string Enter string CopySubmoduleNameToClipboard string RemoveSubmodule string @@ -699,6 +702,7 @@ type TranslationSet struct { BulkSubmoduleOptions string RunningCommand string SubCommitsTitle string + ExitSubview string SubmodulesTitle string NavigationTitle string SuggestionsCheatsheetTitle string @@ -861,6 +865,7 @@ type TranslationSet struct { MarkedBaseCommitStatus string MarkAsBaseCommit string MarkAsBaseCommitTooltip string + CancelMarkedBaseCommit string MarkedCommitMarker string FailedToOpenURL string InvalidLazygitEditURL string @@ -870,6 +875,7 @@ type TranslationSet struct { QuickStartInteractiveRebaseTooltip string CannotQuickStartInteractiveRebase string ToggleRangeSelect string + DismissRangeSelect string RangeSelectUp string RangeSelectDown string RangeSelectNotSupported string @@ -1349,6 +1355,7 @@ func EnglishTranslationSet() *TranslationSet { DiscardSelection: `Discard`, DiscardSelectionTooltip: "When unstaged change is selected, discard the change using `git reset`. When staged change is selected, unstage the change.", ToggleRangeSelect: "Toggle range select", + DismissRangeSelect: "Dismiss range select", ToggleSelectHunk: "Toggle hunk selection", SelectHunk: "Select hunks", SelectLineByLine: "Select line-by-line", @@ -1667,6 +1674,7 @@ func EnglishTranslationSet() *TranslationSet { RenameBranchWarning: "This branch is tracking a remote. This action will only rename the local branch name, not the name of the remote branch. Continue?", OpenKeybindingsMenu: "Open keybindings menu", ResetCherryPick: "Reset copied (cherry-picked) commits selection", + ResetCherryPickShort: "Reset copied commits", NextTab: "Next tab", PrevTab: "Previous tab", CantUndoWhileRebasing: "Can't undo while rebasing", @@ -1700,6 +1708,7 @@ func EnglishTranslationSet() *TranslationSet { SwapDiff: "Reverse diff direction", ViewDiffingOptions: "View diffing options", ViewDiffingOptionsTooltip: "View options relating to diffing two refs e.g. diffing against selected ref, entering ref to diff against, and reversing the diff direction.", + CancelDiffingMode: "Cancel diffing mode", // the actual view is the extras view which I intend to give more tabs in future but for now we'll only mention the command log part OpenCommandLogMenu: "View command log options", OpenCommandLogMenuTooltip: "View options for the command log e.g. show/hide the command log and focus the command log.", @@ -1739,6 +1748,7 @@ func EnglishTranslationSet() *TranslationSet { AndResetSubmodules: "And reset submodules", Enter: "Enter", EnterSubmoduleTooltip: "Enter submodule. After entering the submodule, you can press `{{.escape}}` to escape back to the parent repo.", + BackToParentRepo: "Back to parent repo", CopySubmoduleNameToClipboard: "Copy submodule name to clipboard", RemoveSubmodule: "Remove submodule", RemoveSubmodulePrompt: "Are you sure you want to remove submodule '%s' and its corresponding directory? This is irreversible.", @@ -1766,6 +1776,7 @@ func EnglishTranslationSet() *TranslationSet { BulkSubmoduleOptions: "Bulk submodule options", RunningCommand: "Running command", SubCommitsTitle: "Sub-commits", + ExitSubview: "Exit subview", SubmodulesTitle: "Submodules", NavigationTitle: "List panel navigation", SuggestionsCheatsheetTitle: "Suggestions", @@ -1925,6 +1936,7 @@ func EnglishTranslationSet() *TranslationSet { MarkedBaseCommitStatus: "Marked a base commit for rebase", MarkAsBaseCommit: "Mark as base commit for rebase", MarkAsBaseCommitTooltip: "Select a base commit for the next rebase. When you rebase onto a branch, only commits above the base commit will be brought across. This uses the `git rebase --onto` command.", + CancelMarkedBaseCommit: "Cancel marked base commit", MarkedCommitMarker: "↑↑↑ Will rebase from here ↑↑↑", FailedToOpenURL: "Failed to open URL %s\n\nError: %v", InvalidLazygitEditURL: "Invalid lazygit-edit URL format: %s", diff --git a/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go b/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go index d9c24aeb7fd..def9a53c742 100644 --- a/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go +++ b/pkg/integration/tests/ui/keybinding_suggestions_when_switching_repos.go @@ -31,12 +31,12 @@ var KeybindingSuggestionsWhenSwitchingRepos = NewIntegrationTest(NewIntegrationT t.Views().Files().Focus() t.Views().Options().Content( - Equals("Commit: c | Stash: s | Reset: D | Keybindings: ? | Cancel: ")) + Equals("Commit: c | Stash: s | Reset: D | Keybindings: ?")) switchToRepo("other") switchToRepo("repo") t.Views().Options().Content( - Equals("Commit: c | Stash: s | Reset: D | Keybindings: ? | Cancel: ")) + Equals("Commit: c | Stash: s | Reset: D | Keybindings: ?")) }, })