(repo *cache.RepoCache)
| 175 | } |
| 176 | |
| 177 | func newBugWithEditor(repo *cache.RepoCache) error { |
| 178 | // This is somewhat hacky. |
| 179 | // As there is no way to pause gocui, run the editor and restart gocui, |
| 180 | // we have to stop it entirely and start a new one later. |
| 181 | // |
| 182 | // - an error channel is used to route the returned error of this new |
| 183 | // instance into the original launch function |
| 184 | // - a custom error (errTerminateMainloop) is used to terminate the original |
| 185 | // instance's mainLoop. This error is then filtered. |
| 186 | |
| 187 | ui.g.Close() |
| 188 | ui.g = nil |
| 189 | |
| 190 | title, message, err := buginput.BugCreateEditorInput(ui.cache, "", "") |
| 191 | |
| 192 | if err != nil && err != buginput.ErrEmptyTitle { |
| 193 | return err |
| 194 | } |
| 195 | |
| 196 | var b *cache.BugCache |
| 197 | if err == buginput.ErrEmptyTitle { |
| 198 | ui.msgPopup.Activate(msgPopupErrorTitle, "Empty title, aborting.") |
| 199 | initGui(nil) |
| 200 | |
| 201 | return errTerminateMainloop |
| 202 | } else { |
| 203 | b, _, err = repo.Bugs().New( |
| 204 | text.CleanupOneLine(title), |
| 205 | text.Cleanup(message), |
| 206 | ) |
| 207 | if err != nil { |
| 208 | return err |
| 209 | } |
| 210 | |
| 211 | initGui(func(ui *termUI) error { |
| 212 | ui.showBug.SetBug(b) |
| 213 | return ui.activateWindow(ui.showBug) |
| 214 | }) |
| 215 | |
| 216 | return errTerminateMainloop |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func addCommentWithEditor(bug *cache.BugCache) error { |
| 221 | // This is somewhat hacky. |
no test coverage detected