diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 62715d3b1..ab470a626 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -1015,7 +1015,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Contexts: []string{"staging"}, Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, - Handler: gui.handleStageSelection, + Handler: gui.handleToggleStagedSelection, Description: gui.Tr.SLocalize("StageSelection"), }, { diff --git a/pkg/gui/staging_panel.go b/pkg/gui/staging_panel.go index 5fa7317de..3de1d9b32 100644 --- a/pkg/gui/staging_panel.go +++ b/pkg/gui/staging_panel.go @@ -99,26 +99,27 @@ func (gui *Gui) handleStagingEscape(g *gocui.Gui, v *gocui.View) error { return gui.switchFocus(gui.g, nil, gui.getFilesView()) } -func (gui *Gui) handleStageSelection(g *gocui.Gui, v *gocui.View) error { - return gui.applySelectionWithPrompt(false) +func (gui *Gui) handleToggleStagedSelection(g *gocui.Gui, v *gocui.View) error { + state := gui.State.Panels.LineByLine + + return gui.applySelection(state.SecondaryFocused) } func (gui *Gui) handleResetSelection(g *gocui.Gui, v *gocui.View) error { - return gui.applySelectionWithPrompt(true) -} - -func (gui *Gui) applySelectionWithPrompt(reverse bool) error { state := gui.State.Panels.LineByLine - if !reverse && state.SecondaryFocused { - return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("CantStageStaged")) - } else if reverse && !state.SecondaryFocused && !gui.Config.GetUserConfig().GetBool("gui.skipUnstageLineWarning") { - return gui.createConfirmationPanel(gui.g, gui.getMainView(), false, "unstage lines", "Are you sure you want to unstage these lines? It is irreversible.\nTo disable this dialogue set the config key of 'gui.skipUnstageLineWarning' to true", func(*gocui.Gui, *gocui.View) error { - return gui.applySelection(reverse) - }, nil) + if state.SecondaryFocused { + // for backwards compatibility + return gui.applySelection(true) } - return gui.applySelection(reverse) + if gui.Config.GetUserConfig().GetBool("gui.skipUnstageLineWarning") { + return gui.createConfirmationPanel(gui.g, gui.getMainView(), false, "unstage lines", "Are you sure you want to delete the selected lines (git reset)? It is irreversible.\nTo disable this dialogue set the config key of 'gui.skipUnstageLineWarning' to true", func(*gocui.Gui, *gocui.View) error { + return gui.applySelection(true) + }, nil) + } else { + return gui.applySelection(true) + } } func (gui *Gui) applySelection(reverse bool) error { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 55c08e920..96f0f4986 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -501,10 +501,10 @@ func addEnglish(i18nObject *i18n.Bundle) error { Other: `select hunk`, }, &i18n.Message{ ID: "StageSelection", - Other: `stage selection`, + Other: `toggle line staged / unstaged`, }, &i18n.Message{ ID: "ResetSelection", - Other: `reset selection`, + Other: `delete change (git reset)`, }, &i18n.Message{ ID: "ToggleDragSelect", Other: `toggle drag select`,