| 218 | } |
| 219 | |
| 220 | func 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 | |
| 251 | func editCommentWithEditor(bug *cache.BugCache, target entity.CombinedId, preMessage string) error { |
| 252 | // This is somewhat hacky. |