MCPcopy Index your code
hub / github.com/git-bug/git-bug / addCommentWithEditor

Function addCommentWithEditor

termui/termui.go:220–249  ·  view source on GitHub ↗
(bug *cache.BugCache)

Source from the content-addressed store, hash-verified

218}
219
220func addCommentWithEditor(bug *cache.BugCache) error {
221 // This is somewhat hacky.
222 // As there is no way to pause gocui, run the editor and restart gocui,
223 // we have to stop it entirely and start a new one later.
224 //
225 // - an error channel is used to route the returned error of this new
226 // instance into the original launch function
227 // - a custom error (errTerminateMainloop) is used to terminate the original
228 // instance's mainLoop. This error is then filtered.
229
230 ui.g.Close()
231 ui.g = nil
232
233 message, err := buginput.BugCommentEditorInput(ui.cache, "")
234 if err != nil && err != buginput.ErrEmptyMessage {
235 return err
236 }
237 if err == buginput.ErrEmptyMessage {
238 ui.msgPopup.Activate(msgPopupErrorTitle, "Empty message, aborting.")
239 } else {
240 _, _, err := bug.AddComment(text.Cleanup(message))
241 if err != nil {
242 return err
243 }
244 }
245
246 initGui(nil)
247
248 return errTerminateMainloop
249}
250
251func editCommentWithEditor(bug *cache.BugCache, target entity.CombinedId, preMessage string) error {
252 // This is somewhat hacky.

Callers 1

commentMethod · 0.85

Calls 5

CleanupFunction · 0.92
initGuiFunction · 0.85
CloseMethod · 0.65
ActivateMethod · 0.45
AddCommentMethod · 0.45

Tested by

no test coverage detected