2020-08-22 00:49:02 +02:00
|
|
|
package gui
|
|
|
|
|
2023-02-10 14:44:15 +02:00
|
|
|
import (
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
|
|
|
)
|
2022-08-07 03:34:53 +02:00
|
|
|
|
2020-08-22 00:49:02 +02:00
|
|
|
// list panel functions
|
|
|
|
|
2023-02-10 14:44:15 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-11-21 03:48:49 +02:00
|
|
|
func (gui *Gui) subCommitsRenderToMain() error {
|
2022-02-05 08:04:10 +02:00
|
|
|
commit := gui.State.Contexts.SubCommits.GetSelected()
|
2022-08-07 03:34:53 +02:00
|
|
|
var task types.UpdateTask
|
2020-08-22 00:49:02 +02:00
|
|
|
if commit == nil {
|
2022-08-07 03:34:53 +02:00
|
|
|
task = types.NewRenderStringTask("No commits")
|
2020-08-22 00:49:02 +02:00
|
|
|
} else {
|
2023-02-03 21:20:20 +02:00
|
|
|
cmdObj := gui.git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath(),
|
|
|
|
gui.IgnoreWhitespaceInDiffView)
|
2020-08-22 00:49:02 +02:00
|
|
|
|
2022-08-07 03:34:53 +02:00
|
|
|
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
2020-08-22 00:49:02 +02:00
|
|
|
}
|
|
|
|
|
2022-08-07 03:34:53 +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
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|