| 249 | } |
| 250 | |
| 251 | func 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 | |
| 286 | func setTitleWithEditor(bug *cache.BugCache) error { |
| 287 | // This is somewhat hacky. |