1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-14 11:23:09 +02:00
lazygit/pkg/gui/sub_commits_panel.go

44 lines
1.0 KiB
Go
Raw Normal View History

2020-08-22 00:49:02 +02:00
package gui
import (
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
)
2020-08-22 00:49:02 +02:00
// list panel functions
func (gui *Gui) onSubCommitFocus() error {
context := gui.State.Contexts.SubCommits
if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() {
context.SetLimitCommits(false)
go utils.Safe(func() {
if err := gui.refreshSubCommitsWithLimit(); err != nil {
_ = gui.c.Error(err)
}
})
}
return nil
}
func (gui *Gui) subCommitsRenderToMain() error {
2022-02-05 08:04:10 +02:00
commit := gui.State.Contexts.SubCommits.GetSelected()
var task types.UpdateTask
2020-08-22 00:49:02 +02:00
if commit == nil {
task = types.NewRenderStringTask("No commits")
2020-08-22 00:49:02 +02:00
} else {
cmdObj := gui.git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath(),
gui.IgnoreWhitespaceInDiffView)
2020-08-22 00:49:02 +02:00
task = types.NewRunPtyTask(cmdObj.GetCmd())
2020-08-22 00:49:02 +02:00
}
return gui.c.RenderToMainViews(types.RefreshMainOpts{
Pair: gui.c.MainViewPairs().Normal,
Main: &types.ViewUpdateOpts{
Title: "Commit",
Task: task,
2020-08-22 00:49:02 +02:00
},
})
}