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

Function newBugWithEditor

termui/termui.go:177–218  ·  view source on GitHub ↗
(repo *cache.RepoCache)

Source from the content-addressed store, hash-verified

175}
176
177func 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
220func addCommentWithEditor(bug *cache.BugCache) error {
221 // This is somewhat hacky.

Callers 1

newBugMethod · 0.85

Calls 9

CleanupOneLineFunction · 0.92
CleanupFunction · 0.92
initGuiFunction · 0.85
BugsMethod · 0.80
activateWindowMethod · 0.80
CloseMethod · 0.65
ActivateMethod · 0.45
NewMethod · 0.45
SetBugMethod · 0.45

Tested by

no test coverage detected