Skip to content

Commit

Permalink
fix: use suggestion function from controller
Browse files Browse the repository at this point in the history
  • Loading branch information
2KAbhishek committed Dec 3, 2023
1 parent 3b7c5a0 commit 454d4c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion pkg/gui/controllers/commit_description_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ func (self *CommitDescriptionController) confirm() error {
}

func (self *CommitDescriptionController) openCommitMenu() error {
return self.c.Helpers().Commits.OpenCommitMenu()
authorSuggestion := self.c.Helpers().Suggestions.GetAuthorsSuggestionsFunc()
return self.c.Helpers().Commits.OpenCommitMenu(authorSuggestion)
}
3 changes: 2 additions & 1 deletion pkg/gui/controllers/commit_message_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,6 @@ func (self *CommitMessageController) close() error {
}

func (self *CommitMessageController) openCommitMenu() error {
return self.c.Helpers().Commits.OpenCommitMenu()
authorSuggestion := self.c.Helpers().Suggestions.GetAuthorsSuggestionsFunc()
return self.c.Helpers().Commits.OpenCommitMenu(authorSuggestion)
}
10 changes: 4 additions & 6 deletions pkg/gui/controllers/helpers/commits_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ func (self *CommitsHelper) commitMessageContexts() []types.Context {
}
}

func (self *CommitsHelper) OpenCommitMenu() error {
func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.Suggestion) error {
menuItems := []*types.MenuItem{
{
Label: self.c.Tr.AddCoAuthor,
OnPress: func() error {
return self.addCoAuthor()
return self.addCoAuthor(suggestionFunc)
},
Key: 'c',
},
Expand All @@ -215,12 +215,10 @@ func (self *CommitsHelper) OpenCommitMenu() error {
})
}

func (self *CommitsHelper) addCoAuthor() error {
suggestionHelper := &SuggestionsHelper{}

func (self *CommitsHelper) addCoAuthor(suggestionFunc func(string) []*types.Suggestion) error {
return self.c.Prompt(types.PromptOpts{
Title: self.c.Tr.AddCoAuthorPromptTitle,
FindSuggestionsFunc: suggestionHelper.GetAuthorsSuggestionsFunc(),
FindSuggestionsFunc: suggestionFunc,
HandleConfirm: func(value string) error {
commitMessage := self.JoinCommitMessageAndDescription()
coAuthorString := commitMessage + "\nCo-authored-by: " + value
Expand Down

0 comments on commit 454d4c6

Please sign in to comment.