diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-11 19:28:32 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-11 19:28:32 +0200 |
commit | 9cbd5b4ee113c660377ffe9c01ca374d6addfef4 (patch) | |
tree | 8720b18cba789d27f28b3ce024f7caa90e93ccc7 /termui/termui.go | |
parent | 30e38aab0849d28eaea11c5e1f9f9423a0999e0d (diff) | |
download | git-bug-9cbd5b4ee113c660377ffe9c01ca374d6addfef4.tar.gz |
termui: allow to change the bug query
Diffstat (limited to 'termui/termui.go')
-rw-r--r-- | termui/termui.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/termui/termui.go b/termui/termui.go index 879ec2ea..54324c61 100644 --- a/termui/termui.go +++ b/termui/termui.go @@ -262,6 +262,40 @@ func setTitleWithEditor(bug *cache.BugCache) error { return errTerminateMainloop } +func editQueryWithEditor(bt *bugTable) error { + // This is somewhat hacky. + // As there is no way to pause gocui, run the editor and restart gocui, + // we have to stop it entirely and start a new one later. + // + // - an error channel is used to route the returned error of this new + // instance into the original launch function + // - a custom error (errTerminateMainloop) is used to terminate the original + // instance's mainLoop. This error is then filtered. + + ui.g.Close() + ui.g = nil + + queryStr, err := input.QueryEditorInput(bt.repo.Repository(), bt.queryStr) + + if err != nil { + return err + } + + bt.queryStr = queryStr + + query, err := cache.ParseQuery(queryStr) + + if err != nil { + ui.msgPopup.Activate(msgPopupErrorTitle, err.Error()) + } else { + bt.query = query + } + + initGui(nil) + + return errTerminateMainloop +} + func maxInt(a, b int) int { if a > b { return a |