mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Begin refactoring gui
This begins a big refactor of moving more code out of the Gui struct into contexts, controllers, and helpers. We also move some code into structs in the gui package purely for the sake of better encapsulation
This commit is contained in:
@ -113,3 +113,42 @@ func (self *MergeConflictsHelper) SwitchToMerge(path string) error {
|
||||
func (self *MergeConflictsHelper) context() *context.MergeConflictsContext {
|
||||
return self.contexts.MergeConflicts
|
||||
}
|
||||
|
||||
func (self *MergeConflictsHelper) Render(isFocused bool) error {
|
||||
content := self.context().GetContentToRender(isFocused)
|
||||
|
||||
var task types.UpdateTask
|
||||
if self.context().IsUserScrolling() {
|
||||
task = types.NewRenderStringWithoutScrollTask(content)
|
||||
} else {
|
||||
originY := self.context().GetOriginY()
|
||||
task = types.NewRenderStringWithScrollTask(content, 0, originY)
|
||||
}
|
||||
|
||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||
Pair: self.c.MainViewPairs().MergeConflicts,
|
||||
Main: &types.ViewUpdateOpts{
|
||||
Task: task,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (self *MergeConflictsHelper) RefreshMergeState() error {
|
||||
self.contexts.MergeConflicts.GetMutex().Lock()
|
||||
defer self.contexts.MergeConflicts.GetMutex().Unlock()
|
||||
|
||||
if self.c.CurrentContext().GetKey() != context.MERGE_CONFLICTS_CONTEXT_KEY {
|
||||
return nil
|
||||
}
|
||||
|
||||
hasConflicts, err := self.SetConflictsAndRender(self.contexts.MergeConflicts.GetState().GetPath(), true)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
||||
if !hasConflicts {
|
||||
return self.EscapeMerge()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user