Skip to content

Commit 454d4c6

Browse files
committed
fix: use suggestion function from controller
1 parent 3b7c5a0 commit 454d4c6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pkg/gui/controllers/commit_description_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ func (self *CommitDescriptionController) confirm() error {
6565
}
6666

6767
func (self *CommitDescriptionController) openCommitMenu() error {
68-
return self.c.Helpers().Commits.OpenCommitMenu()
68+
authorSuggestion := self.c.Helpers().Suggestions.GetAuthorsSuggestionsFunc()
69+
return self.c.Helpers().Commits.OpenCommitMenu(authorSuggestion)
6970
}

pkg/gui/controllers/commit_message_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,6 @@ func (self *CommitMessageController) close() error {
128128
}
129129

130130
func (self *CommitMessageController) openCommitMenu() error {
131-
return self.c.Helpers().Commits.OpenCommitMenu()
131+
authorSuggestion := self.c.Helpers().Suggestions.GetAuthorsSuggestionsFunc()
132+
return self.c.Helpers().Commits.OpenCommitMenu(authorSuggestion)
132133
}

pkg/gui/controllers/helpers/commits_helper.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ func (self *CommitsHelper) commitMessageContexts() []types.Context {
192192
}
193193
}
194194

195-
func (self *CommitsHelper) OpenCommitMenu() error {
195+
func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.Suggestion) error {
196196
menuItems := []*types.MenuItem{
197197
{
198198
Label: self.c.Tr.AddCoAuthor,
199199
OnPress: func() error {
200-
return self.addCoAuthor()
200+
return self.addCoAuthor(suggestionFunc)
201201
},
202202
Key: 'c',
203203
},
@@ -215,12 +215,10 @@ func (self *CommitsHelper) OpenCommitMenu() error {
215215
})
216216
}
217217

218-
func (self *CommitsHelper) addCoAuthor() error {
219-
suggestionHelper := &SuggestionsHelper{}
220-
218+
func (self *CommitsHelper) addCoAuthor(suggestionFunc func(string) []*types.Suggestion) error {
221219
return self.c.Prompt(types.PromptOpts{
222220
Title: self.c.Tr.AddCoAuthorPromptTitle,
223-
FindSuggestionsFunc: suggestionHelper.GetAuthorsSuggestionsFunc(),
221+
FindSuggestionsFunc: suggestionFunc,
224222
HandleConfirm: func(value string) error {
225223
commitMessage := self.JoinCommitMessageAndDescription()
226224
coAuthorString := commitMessage + "\nCo-authored-by: " + value

0 commit comments

Comments
 (0)