diff options
-rw-r--r-- | pkg/gui/controllers.go | 12 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/working_tree_helper.go | 40 |
2 files changed, 25 insertions, 27 deletions
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 4efb5e1ff..98a15b3d8 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -24,6 +24,10 @@ func (gui *Gui) resetControllers() { rebaseHelper := helpers.NewMergeAndRebaseHelper(helperCommon, gui.State.Contexts, gui.git, refsHelper) suggestionsHelper := helpers.NewSuggestionsHelper(helperCommon, model, gui.refreshSuggestions) + setCommitMessage := gui.getSetTextareaTextFn(func() *gocui.View { return gui.Views.CommitMessage }) + getSavedCommitMessage := func() string { + return gui.State.savedCommitMessage + } gui.helpers = &helpers.Helpers{ Refs: refsHelper, Host: helpers.NewHostHelper(helperCommon, gui.git), @@ -31,7 +35,7 @@ func (gui *Gui) resetControllers() { Bisect: helpers.NewBisectHelper(helperCommon, gui.git), Suggestions: suggestionsHelper, Files: helpers.NewFilesHelper(helperCommon, gui.git, osCommand), - WorkingTree: helpers.NewWorkingTreeHelper(helperCommon, gui.git, model), + WorkingTree: helpers.NewWorkingTreeHelper(helperCommon, gui.git, gui.State.Contexts, refsHelper, model, setCommitMessage, getSavedCommitMessage), Tags: helpers.NewTagsHelper(helperCommon, gui.git), GPG: helpers.NewGpgHelper(helperCommon, gui.os, gui.git), MergeAndRebase: rebaseHelper, @@ -76,16 +80,10 @@ func (gui *Gui) resetControllers() { bisectController := controllers.NewBisectController(common) - getSavedCommitMessage := func() string { - return gui.State.savedCommitMessage - } - getCommitMessage := func() string { return strings.TrimSpace(gui.Views.CommitMessage.TextArea.GetContent()) } - setCommitMessage := gui.getSetTextareaTextFn(func() *gocui.View { return gui.Views.CommitMessage }) - onCommitAttempt := func(message string) { gui.State.savedCommitMessage = message gui.Views.CommitMessage.ClearTextArea() diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go index a40bcbc6e..17850b994 100644 --- a/pkg/gui/controllers/helpers/working_tree_helper.go +++ b/pkg/gui/controllers/helpers/working_tree_helper.go @@ -2,13 +2,14 @@ package helpers import ( "fmt" - "regexp" + "regexp" + "github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/commands/models" - "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/config" - "github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/gui/context" + "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/utils" ) type IWorkingTreeHelper interface { @@ -19,30 +20,30 @@ type IWorkingTreeHelper interface { } type WorkingTreeHelper struct { - c *types.HelperCommon - git *commands.GitCommand - contexts *context.ContextTree - refHelper *RefsHelper - model *types.Model + c *types.HelperCommon + git *commands.GitCommand + contexts *context.ContextTree + refHelper *RefsHelper + model *types.Model setCommitMessage func(message string) getSavedCommitMessage func() string } func NewWorkingTreeHelper( - c *types.HelperCommon, - git *commands.GitCommand, - contexts *context.ContextTree, - refHelper *RefsHelper, - model *types.Model, + c *types.HelperCommon, + git *commands.GitCommand, + contexts *context.ContextTree, + refHelper *RefsHelper, + model *types.Model, setCommitMessage func(message string), getSavedCommitMessage func() string, ) *WorkingTreeHelper { return &WorkingTreeHelper{ - c: c, - git: git, - contexts: contexts, - refHelper: refHelper, - model: model, + c: c, + git: git, + contexts: contexts, + refHelper: refHelper, + model: model, setCommitMessage: setCommitMessage, getSavedCommitMessage: getSavedCommitMessage, } @@ -190,7 +191,7 @@ func (self *WorkingTreeHelper) prepareFilesForCommit() error { return err } - return self.syncRefresh(); + return self.syncRefresh() } return nil @@ -204,4 +205,3 @@ func (self *WorkingTreeHelper) commitPrefixConfigForRepo() *config.CommitPrefixC return &cfg } - |