mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Remove return value of RenderToMainViews and some related functions
This commit is contained in:
@ -16,7 +16,7 @@ type BaseContext struct {
|
|||||||
keybindingsFns []types.KeybindingsFn
|
keybindingsFns []types.KeybindingsFn
|
||||||
mouseKeybindingsFns []types.MouseKeybindingsFn
|
mouseKeybindingsFns []types.MouseKeybindingsFn
|
||||||
onClickFn func() error
|
onClickFn func() error
|
||||||
onRenderToMainFn func() error
|
onRenderToMainFn func()
|
||||||
onFocusFn onFocusFn
|
onFocusFn onFocusFn
|
||||||
onFocusLostFn onFocusLostFn
|
onFocusLostFn onFocusLostFn
|
||||||
|
|
||||||
@ -148,13 +148,13 @@ func (self *BaseContext) GetOnClick() func() error {
|
|||||||
return self.onClickFn
|
return self.onClickFn
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BaseContext) AddOnRenderToMainFn(fn func() error) {
|
func (self *BaseContext) AddOnRenderToMainFn(fn func()) {
|
||||||
if fn != nil {
|
if fn != nil {
|
||||||
self.onRenderToMainFn = fn
|
self.onRenderToMainFn = fn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BaseContext) GetOnRenderToMain() func() error {
|
func (self *BaseContext) GetOnRenderToMain() func() {
|
||||||
return self.onRenderToMainFn
|
return self.onRenderToMainFn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,9 +43,7 @@ func (self *SimpleContext) HandleFocus(opts types.OnFocusOpts) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.onRenderToMainFn != nil {
|
if self.onRenderToMainFn != nil {
|
||||||
if err := self.onRenderToMainFn(); err != nil {
|
self.onRenderToMainFn()
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -63,10 +61,8 @@ func (self *SimpleContext) HandleFocusLost(opts types.OnFocusLostOpts) error {
|
|||||||
func (self *SimpleContext) HandleRender() {
|
func (self *SimpleContext) HandleRender() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SimpleContext) HandleRenderToMain() error {
|
func (self *SimpleContext) HandleRenderToMain() {
|
||||||
if self.onRenderToMainFn != nil {
|
if self.onRenderToMainFn != nil {
|
||||||
return self.onRenderToMainFn()
|
self.onRenderToMainFn()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ func (self *baseController) GetOnClick() func() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *baseController) GetOnRenderToMain() func() error {
|
func (self *baseController) GetOnRenderToMain() func() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,9 +170,9 @@ func (self *BranchesController) GetKeybindings(opts types.KeybindingsOpts) []*ty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BranchesController) GetOnRenderToMain() func() error {
|
func (self *BranchesController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
branch := self.context().GetSelected()
|
branch := self.context().GetSelected()
|
||||||
if branch == nil {
|
if branch == nil {
|
||||||
@ -183,7 +183,7 @@ func (self *BranchesController) GetOnRenderToMain() func() error {
|
|||||||
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: self.c.Tr.LogTitle,
|
Title: self.c.Tr.LogTitle,
|
||||||
|
@ -129,11 +129,11 @@ func (self *CommitFilesController) context() *context.CommitFilesContext {
|
|||||||
return self.c.Contexts().CommitFiles
|
return self.c.Contexts().CommitFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitFilesController) GetOnRenderToMain() func() error {
|
func (self *CommitFilesController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
node := self.context().GetSelected()
|
node := self.context().GetSelected()
|
||||||
if node == nil {
|
if node == nil {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
from, to := self.context().GetFromAndToForDiff()
|
from, to := self.context().GetFromAndToForDiff()
|
||||||
@ -147,7 +147,7 @@ func (self *CommitFilesController) GetOnRenderToMain() func() error {
|
|||||||
pair = self.c.MainViewPairs().PatchBuilding
|
pair = self.c.MainViewPairs().PatchBuilding
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: pair,
|
Pair: pair,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: self.c.Tr.Patch,
|
Title: self.c.Tr.Patch,
|
||||||
|
@ -102,7 +102,8 @@ func (self *ContextLinesController) applyChange() error {
|
|||||||
case context.STAGING_MAIN_CONTEXT_KEY, context.STAGING_SECONDARY_CONTEXT_KEY:
|
case context.STAGING_MAIN_CONTEXT_KEY, context.STAGING_SECONDARY_CONTEXT_KEY:
|
||||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STAGING}})
|
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STAGING}})
|
||||||
default:
|
default:
|
||||||
return currentContext.HandleRenderToMain()
|
currentContext.HandleRenderToMain()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,13 +224,13 @@ func (self *FilesController) GetMouseKeybindings(opts types.KeybindingsOpts) []*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *FilesController) GetOnRenderToMain() func() error {
|
func (self *FilesController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
node := self.context().GetSelected()
|
node := self.context().GetSelected()
|
||||||
|
|
||||||
if node == nil {
|
if node == nil {
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: self.c.Tr.DiffTitle,
|
Title: self.c.Tr.DiffTitle,
|
||||||
@ -238,16 +238,18 @@ func (self *FilesController) GetOnRenderToMain() func() error {
|
|||||||
Task: types.NewRenderStringTask(self.c.Tr.NoChangedFiles),
|
Task: types.NewRenderStringTask(self.c.Tr.NoChangedFiles),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.File != nil && node.File.HasInlineMergeConflicts {
|
if node.File != nil && node.File.HasInlineMergeConflicts {
|
||||||
hasConflicts, err := self.c.Helpers().MergeConflicts.SetMergeState(node.GetPath())
|
hasConflicts, err := self.c.Helpers().MergeConflicts.SetMergeState(node.GetPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if hasConflicts {
|
if hasConflicts {
|
||||||
return self.c.Helpers().MergeConflicts.Render()
|
self.c.Helpers().MergeConflicts.Render()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +292,7 @@ func (self *FilesController) GetOnRenderToMain() func() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(refreshOpts)
|
self.c.RenderToMainViews(refreshOpts)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func (self *DiffHelper) ExitDiffMode() error {
|
|||||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *DiffHelper) RenderDiff() error {
|
func (self *DiffHelper) RenderDiff() {
|
||||||
args := self.DiffArgs()
|
args := self.DiffArgs()
|
||||||
cmdObj := self.c.Git().Diff.DiffCmdObj(args)
|
cmdObj := self.c.Git().Diff.DiffCmdObj(args)
|
||||||
task := types.NewRunPtyTask(cmdObj.GetCmd())
|
task := types.NewRunPtyTask(cmdObj.GetCmd())
|
||||||
@ -91,7 +91,7 @@ func (self *DiffHelper) RenderDiff() error {
|
|||||||
"git diff "+strings.Join(args, " "),
|
"git diff "+strings.Join(args, " "),
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Diff",
|
Title: "Diff",
|
||||||
@ -141,12 +141,12 @@ func (self *DiffHelper) currentlySelectedFilename() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *DiffHelper) WithDiffModeCheck(f func() error) error {
|
func (self *DiffHelper) WithDiffModeCheck(f func()) {
|
||||||
if self.c.Modes().Diffing.Active() {
|
if self.c.Modes().Diffing.Active() {
|
||||||
return self.RenderDiff()
|
self.RenderDiff()
|
||||||
|
} else {
|
||||||
|
f()
|
||||||
}
|
}
|
||||||
|
|
||||||
return f()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *DiffHelper) IgnoringWhitespaceSubTitle() string {
|
func (self *DiffHelper) IgnoringWhitespaceSubTitle() string {
|
||||||
|
@ -100,7 +100,7 @@ func (self *MergeConflictsHelper) context() *context.MergeConflictsContext {
|
|||||||
return self.c.Contexts().MergeConflicts
|
return self.c.Contexts().MergeConflicts
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MergeConflictsHelper) Render() error {
|
func (self *MergeConflictsHelper) Render() {
|
||||||
content := self.context().GetContentToRender()
|
content := self.context().GetContentToRender()
|
||||||
|
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
@ -111,7 +111,7 @@ func (self *MergeConflictsHelper) Render() error {
|
|||||||
task = types.NewRenderStringWithScrollTask(content, 0, originY)
|
task = types.NewRenderStringWithScrollTask(content, 0, originY)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().MergeConflicts,
|
Pair: self.c.MainViewPairs().MergeConflicts,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Task: task,
|
Task: task,
|
||||||
|
@ -101,7 +101,7 @@ func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpt
|
|||||||
|
|
||||||
self.c.Contexts().CustomPatchBuilder.FocusSelection()
|
self.c.Contexts().CustomPatchBuilder.FocusSelection()
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().PatchBuilding,
|
Pair: self.c.MainViewPairs().PatchBuilding,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Task: types.NewRenderStringWithoutScrollTask(mainContent),
|
Task: types.NewRenderStringWithoutScrollTask(mainContent),
|
||||||
@ -112,4 +112,6 @@ func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpt
|
|||||||
Title: self.c.Tr.CustomPatch,
|
Title: self.c.Tr.CustomPatch,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ func (self *RefreshHelper) Refresh(options types.RefreshOptions) error {
|
|||||||
if scopeSet.Includes(types.STAGING) {
|
if scopeSet.Includes(types.STAGING) {
|
||||||
refresh("staging", func() {
|
refresh("staging", func() {
|
||||||
fileWg.Wait()
|
fileWg.Wait()
|
||||||
_ = self.stagingHelper.RefreshStagingPanel(types.OnFocusOpts{})
|
self.stagingHelper.RefreshStagingPanel(types.OnFocusOpts{})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,14 +19,14 @@ func NewStagingHelper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: used from outside this file
|
// NOTE: used from outside this file
|
||||||
func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) error {
|
func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) {
|
||||||
secondaryFocused := self.secondaryStagingFocused()
|
secondaryFocused := self.secondaryStagingFocused()
|
||||||
mainFocused := self.mainStagingFocused()
|
mainFocused := self.mainStagingFocused()
|
||||||
|
|
||||||
// this method could be called when the staging panel is not being used,
|
// this method could be called when the staging panel is not being used,
|
||||||
// in which case we don't want to do anything.
|
// in which case we don't want to do anything.
|
||||||
if !mainFocused && !secondaryFocused {
|
if !mainFocused && !secondaryFocused {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mainSelectedLineIdx := -1
|
mainSelectedLineIdx := -1
|
||||||
@ -49,7 +49,8 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
if file == nil || (!file.HasUnstagedChanges && !file.HasStagedChanges) {
|
if file == nil || (!file.HasUnstagedChanges && !file.HasStagedChanges) {
|
||||||
return self.handleStagingEscape()
|
_ = self.handleStagingEscape()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mainDiff := self.c.Git().WorkingTree.WorktreeFileDiff(file, true, false)
|
mainDiff := self.c.Git().WorkingTree.WorktreeFileDiff(file, true, false)
|
||||||
@ -79,15 +80,18 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro
|
|||||||
secondaryContext.GetMutex().Unlock()
|
secondaryContext.GetMutex().Unlock()
|
||||||
|
|
||||||
if mainState == nil && secondaryState == nil {
|
if mainState == nil && secondaryState == nil {
|
||||||
return self.handleStagingEscape()
|
_ = self.handleStagingEscape()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if mainState == nil && !secondaryFocused {
|
if mainState == nil && !secondaryFocused {
|
||||||
return self.c.Context().Push(secondaryContext, focusOpts)
|
_ = self.c.Context().Push(secondaryContext, focusOpts)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if secondaryState == nil && secondaryFocused {
|
if secondaryState == nil && secondaryFocused {
|
||||||
return self.c.Context().Push(mainContext, focusOpts)
|
_ = self.c.Context().Push(mainContext, focusOpts)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if secondaryFocused {
|
if secondaryFocused {
|
||||||
@ -96,7 +100,7 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro
|
|||||||
self.c.Contexts().Staging.FocusSelection()
|
self.c.Contexts().Staging.FocusSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Staging,
|
Pair: self.c.MainViewPairs().Staging,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Task: types.NewRenderStringWithoutScrollTask(mainContent),
|
Task: types.NewRenderStringWithoutScrollTask(mainContent),
|
||||||
|
@ -272,9 +272,9 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
|
|||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *LocalCommitsController) GetOnRenderToMain() func() error {
|
func (self *LocalCommitsController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
commit := self.context().GetSelected()
|
commit := self.context().GetSelected()
|
||||||
if commit == nil {
|
if commit == nil {
|
||||||
@ -294,7 +294,7 @@ func (self *LocalCommitsController) GetOnRenderToMain() func() error {
|
|||||||
task = self.c.Helpers().Diff.GetUpdateTaskForRenderingCommitsDiff(commit, refRange)
|
task = self.c.Helpers().Diff.GetUpdateTaskForRenderingCommitsDiff(commit, refRange)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Patch",
|
Title: "Patch",
|
||||||
|
@ -151,9 +151,7 @@ func (self *MergeConflictsController) GetOnFocus() func(types.OnFocusOpts) error
|
|||||||
return func(types.OnFocusOpts) error {
|
return func(types.OnFocusOpts) error {
|
||||||
self.c.Views().MergeConflicts.Wrap = false
|
self.c.Views().MergeConflicts.Wrap = false
|
||||||
|
|
||||||
if err := self.c.Helpers().MergeConflicts.Render(); err != nil {
|
self.c.Helpers().MergeConflicts.Render()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
self.context().SetSelectedLineRange()
|
self.context().SetSelectedLineRange()
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ func (self *ReflogCommitsController) context() *context.ReflogCommitsContext {
|
|||||||
return self.c.Contexts().ReflogCommits
|
return self.c.Contexts().ReflogCommits
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ReflogCommitsController) GetOnRenderToMain() func() error {
|
func (self *ReflogCommitsController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
commit := self.context().GetSelected()
|
commit := self.context().GetSelected()
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
if commit == nil {
|
if commit == nil {
|
||||||
@ -50,7 +50,7 @@ func (self *ReflogCommitsController) GetOnRenderToMain() func() error {
|
|||||||
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
task = types.NewRunPtyTask(cmdObj.GetCmd())
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Reflog Entry",
|
Title: "Reflog Entry",
|
||||||
|
@ -105,9 +105,9 @@ func (self *RemoteBranchesController) GetKeybindings(opts types.KeybindingsOpts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *RemoteBranchesController) GetOnRenderToMain() func() error {
|
func (self *RemoteBranchesController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
remoteBranch := self.context().GetSelected()
|
remoteBranch := self.context().GetSelected()
|
||||||
if remoteBranch == nil {
|
if remoteBranch == nil {
|
||||||
@ -117,7 +117,7 @@ func (self *RemoteBranchesController) GetOnRenderToMain() func() error {
|
|||||||
task = types.NewRunCommandTask(cmdObj.GetCmd())
|
task = types.NewRunCommandTask(cmdObj.GetCmd())
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Remote Branch",
|
Title: "Remote Branch",
|
||||||
|
@ -87,9 +87,9 @@ func (self *RemotesController) context() *context.RemotesContext {
|
|||||||
return self.c.Contexts().Remotes
|
return self.c.Contexts().Remotes
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *RemotesController) GetOnRenderToMain() func() error {
|
func (self *RemotesController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
remote := self.context().GetSelected()
|
remote := self.context().GetSelected()
|
||||||
if remote == nil {
|
if remote == nil {
|
||||||
@ -98,7 +98,7 @@ func (self *RemotesController) GetOnRenderToMain() func() error {
|
|||||||
task = types.NewRenderStringTask(fmt.Sprintf("%s\nUrls:\n%s", style.FgGreen.Sprint(remote.Name), strings.Join(remote.Urls, "\n")))
|
task = types.NewRenderStringTask(fmt.Sprintf("%s\nUrls:\n%s", style.FgGreen.Sprint(remote.Name), strings.Join(remote.Urls, "\n")))
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Remote",
|
Title: "Remote",
|
||||||
|
@ -88,7 +88,8 @@ func (self *RenameSimilarityThresholdController) applyChange() error {
|
|||||||
case context.FILES_CONTEXT_KEY:
|
case context.FILES_CONTEXT_KEY:
|
||||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.FILES}})
|
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.FILES}})
|
||||||
default:
|
default:
|
||||||
return currentContext.HandleRenderToMain()
|
currentContext.HandleRenderToMain()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,8 @@ func (self *StagingController) GetOnFocus() func(types.OnFocusOpts) error {
|
|||||||
self.c.Views().Staging.Wrap = false
|
self.c.Views().Staging.Wrap = false
|
||||||
self.c.Views().StagingSecondary.Wrap = false
|
self.c.Views().StagingSecondary.Wrap = false
|
||||||
|
|
||||||
return self.c.Helpers().Staging.RefreshStagingPanel(opts)
|
self.c.Helpers().Staging.RefreshStagingPanel(opts)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +74,9 @@ func (self *StashController) GetKeybindings(opts types.KeybindingsOpts) []*types
|
|||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StashController) GetOnRenderToMain() func() error {
|
func (self *StashController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
stashEntry := self.context().GetSelected()
|
stashEntry := self.context().GetSelected()
|
||||||
if stashEntry == nil {
|
if stashEntry == nil {
|
||||||
@ -87,7 +87,7 @@ func (self *StashController) GetOnRenderToMain() func() error {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Stash",
|
Title: "Stash",
|
||||||
|
@ -61,7 +61,7 @@ func (self *StatusController) GetKeybindings(opts types.KeybindingsOpts) []*type
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Key: opts.GetKey(opts.Config.Status.AllBranchesLogGraph),
|
Key: opts.GetKey(opts.Config.Status.AllBranchesLogGraph),
|
||||||
Handler: self.showAllBranchLogs,
|
Handler: func() error { self.showAllBranchLogs(); return nil },
|
||||||
Description: self.c.Tr.AllBranchesLogGraph,
|
Description: self.c.Tr.AllBranchesLogGraph,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -79,15 +79,15 @@ func (self *StatusController) GetMouseKeybindings(opts types.KeybindingsOpts) []
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StatusController) GetOnRenderToMain() func() error {
|
func (self *StatusController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
switch self.c.UserConfig().Gui.StatusPanelView {
|
switch self.c.UserConfig().Gui.StatusPanelView {
|
||||||
case "dashboard":
|
case "dashboard":
|
||||||
return self.showDashboard()
|
self.showDashboard()
|
||||||
case "allBranchesLog":
|
case "allBranchesLog":
|
||||||
return self.showAllBranchLogs()
|
self.showAllBranchLogs()
|
||||||
default:
|
default:
|
||||||
return self.showDashboard()
|
self.showDashboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,11 +183,11 @@ func (self *StatusController) editConfig() error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StatusController) showAllBranchLogs() error {
|
func (self *StatusController) showAllBranchLogs() {
|
||||||
cmdObj := self.c.Git().Branch.AllBranchesLogCmdObj()
|
cmdObj := self.c.Git().Branch.AllBranchesLogCmdObj()
|
||||||
task := types.NewRunPtyTask(cmdObj.GetCmd())
|
task := types.NewRunPtyTask(cmdObj.GetCmd())
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: self.c.Tr.LogTitle,
|
Title: self.c.Tr.LogTitle,
|
||||||
@ -196,7 +196,7 @@ func (self *StatusController) showAllBranchLogs() error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StatusController) showDashboard() error {
|
func (self *StatusController) showDashboard() {
|
||||||
versionStr := "master"
|
versionStr := "master"
|
||||||
version, err := types.ParseVersionNumber(self.c.GetConfig().GetVersion())
|
version, err := types.ParseVersionNumber(self.c.GetConfig().GetVersion())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -218,7 +218,7 @@ func (self *StatusController) showDashboard() error {
|
|||||||
style.FgMagenta.Sprintf("Become a sponsor: %s", style.PrintSimpleHyperlink(constants.Links.Donate)), // caffeine ain't free
|
style.FgMagenta.Sprintf("Become a sponsor: %s", style.PrintSimpleHyperlink(constants.Links.Donate)), // caffeine ain't free
|
||||||
}, "\n\n") + "\n"
|
}, "\n\n") + "\n"
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: self.c.Tr.StatusTitle,
|
Title: self.c.Tr.StatusTitle,
|
||||||
|
@ -38,9 +38,9 @@ func (self *SubCommitsController) context() *context.SubCommitsContext {
|
|||||||
return self.c.Contexts().SubCommits
|
return self.c.Contexts().SubCommits
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SubCommitsController) GetOnRenderToMain() func() error {
|
func (self *SubCommitsController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
commit := self.context().GetSelected()
|
commit := self.context().GetSelected()
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
if commit == nil {
|
if commit == nil {
|
||||||
@ -50,7 +50,7 @@ func (self *SubCommitsController) GetOnRenderToMain() func() error {
|
|||||||
task = self.c.Helpers().Diff.GetUpdateTaskForRenderingCommitsDiff(commit, refRange)
|
task = self.c.Helpers().Diff.GetUpdateTaskForRenderingCommitsDiff(commit, refRange)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Commit",
|
Title: "Commit",
|
||||||
|
@ -106,9 +106,9 @@ func (self *SubmodulesController) GetOnClick() func() error {
|
|||||||
return self.withItemGraceful(self.enter)
|
return self.withItemGraceful(self.enter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SubmodulesController) GetOnRenderToMain() func() error {
|
func (self *SubmodulesController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
submodule := self.context().GetSelected()
|
submodule := self.context().GetSelected()
|
||||||
if submodule == nil {
|
if submodule == nil {
|
||||||
@ -130,7 +130,7 @@ func (self *SubmodulesController) GetOnRenderToMain() func() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Submodule",
|
Title: "Submodule",
|
||||||
|
@ -87,9 +87,9 @@ func (self *TagsController) GetKeybindings(opts types.KeybindingsOpts) []*types.
|
|||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *TagsController) GetOnRenderToMain() func() error {
|
func (self *TagsController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
return self.c.Helpers().Diff.WithDiffModeCheck(func() error {
|
self.c.Helpers().Diff.WithDiffModeCheck(func() {
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
tag := self.context().GetSelected()
|
tag := self.context().GetSelected()
|
||||||
if tag == nil {
|
if tag == nil {
|
||||||
@ -99,7 +99,7 @@ func (self *TagsController) GetOnRenderToMain() func() error {
|
|||||||
task = types.NewRunCommandTask(cmdObj.GetCmd())
|
task = types.NewRunCommandTask(cmdObj.GetCmd())
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: "Tag",
|
Title: "Tag",
|
||||||
|
@ -75,8 +75,8 @@ func (self *WorktreesController) GetKeybindings(opts types.KeybindingsOpts) []*t
|
|||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *WorktreesController) GetOnRenderToMain() func() error {
|
func (self *WorktreesController) GetOnRenderToMain() func() {
|
||||||
return func() error {
|
return func() {
|
||||||
var task types.UpdateTask
|
var task types.UpdateTask
|
||||||
worktree := self.context().GetSelected()
|
worktree := self.context().GetSelected()
|
||||||
if worktree == nil {
|
if worktree == nil {
|
||||||
@ -102,7 +102,7 @@ func (self *WorktreesController) GetOnRenderToMain() func() error {
|
|||||||
task = types.NewRenderStringTask(builder.String())
|
task = types.NewRenderStringTask(builder.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
Pair: self.c.MainViewPairs().Normal,
|
Pair: self.c.MainViewPairs().Normal,
|
||||||
Main: &types.ViewUpdateOpts{
|
Main: &types.ViewUpdateOpts{
|
||||||
Title: self.c.Tr.WorktreeTitle,
|
Title: self.c.Tr.WorktreeTitle,
|
||||||
|
@ -115,8 +115,8 @@ func (self *guiCommon) OnWorker(f func(gocui.Task) error) {
|
|||||||
self.gui.onWorker(f)
|
self.gui.onWorker(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *guiCommon) RenderToMainViews(opts types.RefreshMainOpts) error {
|
func (self *guiCommon) RenderToMainViews(opts types.RefreshMainOpts) {
|
||||||
return self.gui.refreshMainViews(opts)
|
self.gui.refreshMainViews(opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *guiCommon) MainViewPairs() types.MainViewPairs {
|
func (self *guiCommon) MainViewPairs() types.MainViewPairs {
|
||||||
|
@ -58,7 +58,7 @@ func (gui *Gui) moveMainContextToTop(context types.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) RefreshMainView(opts *types.ViewUpdateOpts, context types.Context) error {
|
func (gui *Gui) RefreshMainView(opts *types.ViewUpdateOpts, context types.Context) {
|
||||||
view := context.GetView()
|
view := context.GetView()
|
||||||
|
|
||||||
if opts.Title != "" {
|
if opts.Title != "" {
|
||||||
@ -69,10 +69,7 @@ func (gui *Gui) RefreshMainView(opts *types.ViewUpdateOpts, context types.Contex
|
|||||||
|
|
||||||
if err := gui.runTaskForView(view, opts.Task); err != nil {
|
if err := gui.runTaskForView(view, opts.Task); err != nil {
|
||||||
gui.c.Log.Error(err)
|
gui.c.Log.Error(err)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) normalMainContextPair() types.MainContextPair {
|
func (gui *Gui) normalMainContextPair() types.MainContextPair {
|
||||||
@ -112,7 +109,7 @@ func (gui *Gui) allMainContextPairs() []types.MainContextPair {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) refreshMainViews(opts types.RefreshMainOpts) error {
|
func (gui *Gui) refreshMainViews(opts types.RefreshMainOpts) {
|
||||||
// need to reset scroll positions of all other main views
|
// need to reset scroll positions of all other main views
|
||||||
for _, pair := range gui.allMainContextPairs() {
|
for _, pair := range gui.allMainContextPairs() {
|
||||||
if pair.Main != opts.Pair.Main {
|
if pair.Main != opts.Pair.Main {
|
||||||
@ -124,15 +121,11 @@ func (gui *Gui) refreshMainViews(opts types.RefreshMainOpts) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.Main != nil {
|
if opts.Main != nil {
|
||||||
if err := gui.RefreshMainView(opts.Main, opts.Pair.Main); err != nil {
|
gui.RefreshMainView(opts.Main, opts.Pair.Main)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Secondary != nil {
|
if opts.Secondary != nil {
|
||||||
if err := gui.RefreshMainView(opts.Secondary, opts.Pair.Secondary); err != nil {
|
gui.RefreshMainView(opts.Secondary, opts.Pair.Secondary)
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else if opts.Pair.Secondary != nil {
|
} else if opts.Pair.Secondary != nil {
|
||||||
opts.Pair.Secondary.GetView().Clear()
|
opts.Pair.Secondary.GetView().Clear()
|
||||||
}
|
}
|
||||||
@ -140,8 +133,6 @@ func (gui *Gui) refreshMainViews(opts types.RefreshMainOpts) error {
|
|||||||
gui.moveMainContextPairToTop(opts.Pair)
|
gui.moveMainContextPairToTop(opts.Pair)
|
||||||
|
|
||||||
gui.splitMainPanel(opts.Secondary != nil)
|
gui.splitMainPanel(opts.Secondary != nil)
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) splitMainPanel(splitMainPanel bool) {
|
func (gui *Gui) splitMainPanel(splitMainPanel bool) {
|
||||||
|
@ -45,7 +45,7 @@ type IGuiCommon interface {
|
|||||||
// allows rendering to main views (i.e. the ones to the right of the side panel)
|
// allows rendering to main views (i.e. the ones to the right of the side panel)
|
||||||
// in such a way that avoids concurrency issues when there are slow commands
|
// in such a way that avoids concurrency issues when there are slow commands
|
||||||
// to display the output of
|
// to display the output of
|
||||||
RenderToMainViews(opts RefreshMainOpts) error
|
RenderToMainViews(opts RefreshMainOpts)
|
||||||
// used purely for the sake of RenderToMainViews to provide the pair of main views we want to render to
|
// used purely for the sake of RenderToMainViews to provide the pair of main views we want to render to
|
||||||
MainViewPairs() MainViewPairs
|
MainViewPairs() MainViewPairs
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ type IBaseContext interface {
|
|||||||
// We'll need to think of a better way to do this.
|
// We'll need to think of a better way to do this.
|
||||||
AddOnClickFn(func() error)
|
AddOnClickFn(func() error)
|
||||||
|
|
||||||
AddOnRenderToMainFn(func() error)
|
AddOnRenderToMainFn(func())
|
||||||
AddOnFocusFn(func(OnFocusOpts) error)
|
AddOnFocusFn(func(OnFocusOpts) error)
|
||||||
AddOnFocusLostFn(func(OnFocusLostOpts) error)
|
AddOnFocusLostFn(func(OnFocusLostOpts) error)
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ type Context interface {
|
|||||||
HandleFocus(opts OnFocusOpts) error
|
HandleFocus(opts OnFocusOpts) error
|
||||||
HandleFocusLost(opts OnFocusLostOpts) error
|
HandleFocusLost(opts OnFocusLostOpts) error
|
||||||
HandleRender()
|
HandleRender()
|
||||||
HandleRenderToMain() error
|
HandleRenderToMain()
|
||||||
}
|
}
|
||||||
|
|
||||||
type ISearchHistoryContext interface {
|
type ISearchHistoryContext interface {
|
||||||
@ -232,7 +232,7 @@ type HasKeybindings interface {
|
|||||||
GetKeybindings(opts KeybindingsOpts) []*Binding
|
GetKeybindings(opts KeybindingsOpts) []*Binding
|
||||||
GetMouseKeybindings(opts KeybindingsOpts) []*gocui.ViewMouseBinding
|
GetMouseKeybindings(opts KeybindingsOpts) []*gocui.ViewMouseBinding
|
||||||
GetOnClick() func() error
|
GetOnClick() func() error
|
||||||
GetOnRenderToMain() func() error
|
GetOnRenderToMain() func()
|
||||||
GetOnFocus() func(OnFocusOpts) error
|
GetOnFocus() func(OnFocusOpts) error
|
||||||
GetOnFocusLost() func(OnFocusLostOpts) error
|
GetOnFocusLost() func(OnFocusLostOpts) error
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user