Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/gui/controllers/staging_controller.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package controllers

import (
"fmt"
"strings"

"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/commands/patch"
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)

Expand Down Expand Up @@ -185,10 +187,20 @@ func (self *StagingController) TogglePanel() error {
}

func (self *StagingController) ToggleStaged() error {
if self.c.AppState.DiffContextSize == 0 {
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextToStage,
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
}

return self.applySelectionAndRefresh(self.staged)
}

func (self *StagingController) DiscardSelection() error {
if self.c.AppState.DiffContextSize == 0 {
return fmt.Errorf(self.c.Tr.Actions.NotEnoughContextToDiscard,
keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView))
}

reset := func() error { return self.applySelectionAndRefresh(true) }

if !self.staged && !self.c.UserConfig().Gui.SkipDiscardChangeWarning {
Expand Down
4 changes: 4 additions & 0 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ type Actions struct {
UnstageFile string
UnstageAllFiles string
StageAllFiles string
NotEnoughContextToStage string
NotEnoughContextToDiscard string
IgnoreExcludeFile string
IgnoreFileErr string
ExcludeFile string
Expand Down Expand Up @@ -1913,6 +1915,8 @@ func EnglishTranslationSet() *TranslationSet {
UnstageFile: "Unstage file",
UnstageAllFiles: "Unstage all files",
StageAllFiles: "Stage all files",
NotEnoughContextToStage: "Staging or unstaging changes is not possible with a diff context size of 0. Increase the context using '%s'.",
NotEnoughContextToDiscard: "Discarding changes is not possible with a diff context size of 0. Increase the context using '%s'.",
IgnoreExcludeFile: "Ignore or exclude file",
IgnoreFileErr: "Cannot ignore .gitignore",
ExcludeFile: "Exclude file",
Expand Down