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

Function setTitleWithEditor

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

Source from the content-addressed store, hash-verified

284}
285
286func setTitleWithEditor(bug *cache.BugCache) error {
287 // This is somewhat hacky.
288 // As there is no way to pause gocui, run the editor and restart gocui,
289 // we have to stop it entirely and start a new one later.
290 //
291 // - an error channel is used to route the returned error of this new
292 // instance into the original launch function
293 // - a custom error (errTerminateMainloop) is used to terminate the original
294 // instance's mainLoop. This error is then filtered.
295
296 ui.g.Close()
297 ui.g = nil
298
299 snap := bug.Snapshot()
300
301 title, err := buginput.BugTitleEditorInput(ui.cache, snap.Title)
302
303 if err != nil && err != buginput.ErrEmptyTitle {
304 return err
305 }
306
307 if err == buginput.ErrEmptyTitle {
308 ui.msgPopup.Activate(msgPopupErrorTitle, "Empty title, aborting.")
309 } else if title == snap.Title {
310 ui.msgPopup.Activate(msgPopupErrorTitle, "No change, aborting.")
311 } else {
312 _, err := bug.SetTitle(text.CleanupOneLine(title))
313 if err != nil {
314 return err
315 }
316 }
317
318 initGui(nil)
319
320 return errTerminateMainloop
321}
322
323func editQueryWithEditor(bt *bugTable) error {
324 // This is somewhat hacky.

Callers 1

setTitleMethod · 0.85

Calls 6

CleanupOneLineFunction · 0.92
initGuiFunction · 0.85
SnapshotMethod · 0.80
SetTitleMethod · 0.80
CloseMethod · 0.65
ActivateMethod · 0.45

Tested by

no test coverage detected