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

Function editCommentWithEditor

termui/termui.go:251–284  ·  view source on GitHub ↗
(bug *cache.BugCache, target entity.CombinedId, preMessage string)

Source from the content-addressed store, hash-verified

249}
250
251func editCommentWithEditor(bug *cache.BugCache, target entity.CombinedId, preMessage string) error {
252 // This is somewhat hacky.
253 // As there is no way to pause gocui, run the editor and restart gocui,
254 // we have to stop it entirely and start a new one later.
255 //
256 // - an error channel is used to route the returned error of this new
257 // instance into the original launch function
258 // - a custom error (errTerminateMainloop) is used to terminate the original
259 // instance's mainLoop. This error is then filtered.
260
261 ui.g.Close()
262 ui.g = nil
263
264 message, err := buginput.BugCommentEditorInput(ui.cache, preMessage)
265 if err != nil && err != buginput.ErrEmptyMessage {
266 return err
267 }
268
269 if err == buginput.ErrEmptyMessage {
270 // TODO: Allow comments to be deleted?
271 ui.msgPopup.Activate(msgPopupErrorTitle, "Empty message, aborting.")
272 } else if message == preMessage {
273 ui.msgPopup.Activate(msgPopupErrorTitle, "No changes found, aborting.")
274 } else {
275 _, err := bug.EditComment(target, text.Cleanup(message))
276 if err != nil {
277 return err
278 }
279 }
280
281 initGui(nil)
282
283 return errTerminateMainloop
284}
285
286func setTitleWithEditor(bug *cache.BugCache) error {
287 // This is somewhat hacky.

Callers 1

editMethod · 0.85

Calls 5

CleanupFunction · 0.92
initGuiFunction · 0.85
EditCommentMethod · 0.80
CloseMethod · 0.65
ActivateMethod · 0.45

Tested by

no test coverage detected