diff --git a/pkg/gui/controllers/commit_diff_actions.go b/pkg/gui/controllers/commit_diff_actions.go index a68a55d94..b5adae259 100644 --- a/pkg/gui/controllers/commit_diff_actions.go +++ b/pkg/gui/controllers/commit_diff_actions.go @@ -1,6 +1,7 @@ package controllers import ( + "errors" "fmt" "github.com/jesseduffield/generics/set" @@ -9,6 +10,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/patch" "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" ) @@ -236,7 +238,8 @@ func (self *CommitDiffActions) DiscardSelection(pane types.DiffPaneContext, firs } commitIndex := self.indexOfTargetCommit(target) if commitIndex == -1 { - return nil + return errors.New(utils.ResolvePlaceholderString(self.c.Tr.CommitNotInCommitsPanel, + map[string]string{"hash": utils.ShortHash(target.to)})) } selection, err := self.selectionByFile(lines) if err != nil { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index e2179d5a0..61f81a1f0 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -750,6 +750,7 @@ type TranslationSet struct { SelectionNotFoundInDiffToast string DiffLinesFileNotFound string DiffLinesNotFound string + CommitNotInCommitsPanel string NoFilesStagedTitle string NoFilesStagedPrompt string BranchNotFoundTitle string @@ -1942,6 +1943,7 @@ func EnglishTranslationSet() *TranslationSet { SelectionNotFoundInDiffToast: "Nothing in the selection could be found in the diff", DiffLinesFileNotFound: "Can't find the file '{{.path}}' that the selected lines belong to", DiffLinesNotFound: "Can't find the selected lines in the diff of '{{.path}}'", + CommitNotInCommitsPanel: "Can't find commit {{.hash}} in the commits panel", CommitPrefixPatternError: "Error in commitPrefix pattern", NoFilesStagedTitle: "No files staged", NoFilesStagedPrompt: "You have not staged any files. Commit all files?",