mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-01 08:28:06 -06:00
Show an error if the commit to discard lines from can't be found
Discarding lines from a commit's diff rewrites the commit with a rebase. For this we look up the commit among the commits of the current branch. If it isn't there, pressing the key does nothing. The disabled reason only allows discarding in a diff of the commits panel, so this shouldn't happen. If it does, the user should see it. Show an error that names the commit instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
56e234e94c
commit
2a3883f502
2 files changed
+6
-1
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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?",
|
||||
|
||||
Reference in new issue
Block a user