Skip to content

Commit eebc39d

Browse files
authored
Show stash name for selected stash (#4673)
- **PR Description** In the Stash panel, show information about the selected stash above the diff of the stash in the main view. This is useful for stash entries with very long names that are not fully visible in the Stash panel. Fixes #4662.
2 parents edcfce2 + 92c9eb6 commit eebc39d

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

pkg/gui/controllers/files_controller.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,14 @@ func (self *FilesController) GetOnRenderToMain() func() {
262262
}
263263
if node.File.ShortStatus == "DU" || node.File.ShortStatus == "UD" {
264264
cmdObj := self.c.Git().Diff.DiffCmdObj([]string{"--base", "--", node.GetPath()})
265-
task := types.NewRunPtyTask(cmdObj.GetCmd())
266-
task.Prefix = message + "\n\n"
265+
prefix := message + "\n\n"
267266
if node.File.ShortStatus == "DU" {
268-
task.Prefix += self.c.Tr.MergeConflictIncomingDiff
267+
prefix += self.c.Tr.MergeConflictIncomingDiff
269268
} else {
270-
task.Prefix += self.c.Tr.MergeConflictCurrentDiff
269+
prefix += self.c.Tr.MergeConflictCurrentDiff
271270
}
272-
task.Prefix += "\n\n"
273-
opts.Main.Task = task
271+
prefix += "\n\n"
272+
opts.Main.Task = types.NewRunPtyTaskWithPrefix(cmdObj.GetCmd(), prefix)
274273
} else {
275274
opts.Main.Task = types.NewRenderStringTask(message)
276275
}

pkg/gui/controllers/helpers/diff_helper.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ func (self *DiffHelper) GetUpdateTaskForRenderingCommitsDiff(commit *models.Comm
6161
args = append(args, path)
6262
}
6363
cmdObj := self.c.Git().Diff.DiffCmdObj(args)
64-
task := types.NewRunPtyTask(cmdObj.GetCmd())
65-
task.Prefix = style.FgYellow.Sprintf("%s %s-%s\n\n", self.c.Tr.ShowingDiffForRange, from.ShortRefName(), to.ShortRefName())
66-
return task
64+
prefix := style.FgYellow.Sprintf("%s %s-%s\n\n", self.c.Tr.ShowingDiffForRange, from.ShortRefName(), to.ShortRefName())
65+
return types.NewRunPtyTaskWithPrefix(cmdObj.GetCmd(), prefix)
6766
}
6867

6968
cmdObj := self.c.Git().Commit.ShowCmdObj(commit.Hash(), self.c.Modes().Filtering.GetPath())
@@ -79,12 +78,12 @@ func (self *DiffHelper) ExitDiffMode() error {
7978
func (self *DiffHelper) RenderDiff() {
8079
args := self.DiffArgs()
8180
cmdObj := self.c.Git().Diff.DiffCmdObj(args)
82-
task := types.NewRunPtyTask(cmdObj.GetCmd())
83-
task.Prefix = style.FgMagenta.Sprintf(
81+
prefix := style.FgMagenta.Sprintf(
8482
"%s %s\n\n",
8583
self.c.Tr.ShowingGitDiff,
8684
"git diff "+strings.Join(args, " "),
8785
)
86+
task := types.NewRunPtyTaskWithPrefix(cmdObj.GetCmd(), prefix)
8887

8988
self.c.RenderToMainViews(types.RefreshMainOpts{
9089
Pair: self.c.MainViewPairs().Normal,

pkg/gui/controllers/stash_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package controllers
33
import (
44
"github.com/jesseduffield/lazygit/pkg/commands/models"
55
"github.com/jesseduffield/lazygit/pkg/gui/context"
6+
"github.com/jesseduffield/lazygit/pkg/gui/style"
67
"github.com/jesseduffield/lazygit/pkg/gui/types"
78
"github.com/jesseduffield/lazygit/pkg/utils"
89
)
@@ -82,8 +83,10 @@ func (self *StashController) GetOnRenderToMain() func() {
8283
if stashEntry == nil {
8384
task = types.NewRenderStringTask(self.c.Tr.NoStashEntries)
8485
} else {
85-
task = types.NewRunPtyTask(
86+
prefix := style.FgYellow.Sprintf("%s\n\n", stashEntry.Description())
87+
task = types.NewRunPtyTaskWithPrefix(
8688
self.c.Git().Stash.ShowStashEntryCmdObj(stashEntry.Index).GetCmd(),
89+
prefix,
8790
)
8891
}
8992

pkg/gui/types/rendering.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,7 @@ func (t *RunPtyTask) IsUpdateTask() {}
9494
func NewRunPtyTask(cmd *exec.Cmd) *RunPtyTask {
9595
return &RunPtyTask{Cmd: cmd}
9696
}
97+
98+
func NewRunPtyTaskWithPrefix(cmd *exec.Cmd, prefix string) *RunPtyTask {
99+
return &RunPtyTask{Cmd: cmd, Prefix: prefix}
100+
}

0 commit comments

Comments
 (0)