| 284 | } |
| 285 | |
| 286 | func 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 | |
| 323 | func editQueryWithEditor(bt *bugTable) error { |
| 324 | // This is somewhat hacky. |