diff --git a/layout.go b/layout.go index 3219f7f..d76f223 100644 --- a/layout.go +++ b/layout.go @@ -156,7 +156,7 @@ func makePrompt(g *gocui.Gui) error { // Select selects conflict `c` as the current conflict displayed on the screen // When selecting a conflict, it updates the side panel, and the code view -func Select(g *gocui.Gui, c *conflict.Conflict, showHelp bool) error { +func Select(g *gocui.Gui, c *conflict.Conflict, showHelp bool) { // Update side panel g.Update(func(g *gocui.Gui) error { v, err := g.View(Panel) @@ -220,22 +220,20 @@ func Select(g *gocui.Gui, c *conflict.Conflict, showHelp bool) error { return nil }) - return nil } // Resolve resolves the provided conflict and moves to the next conflict // in the queue -func Resolve(g *gocui.Gui, v *gocui.View, c *conflict.Conflict, version int) error { +func Resolve(g *gocui.Gui, v *gocui.View, c *conflict.Conflict, version int) { g.Update(func(g *gocui.Gui) error { c.Choice = version Move(g, v, Down) return nil }) - return nil } // Move goes to the next conflict in the list in the provided `direction` -func Move(g *gocui.Gui, v *gocui.View, direction int) error { +func Move(g *gocui.Gui, v *gocui.View, direction int) { originalCur := cur for { @@ -262,7 +260,6 @@ func Move(g *gocui.Gui, v *gocui.View, direction int) error { } Select(g, conflicts[cur], false) - return nil } // Scroll scrolls the two code view panels in `direction` by one line diff --git a/main.go b/main.go index feffb60..583cd51 100644 --- a/main.go +++ b/main.go @@ -72,6 +72,12 @@ func runUI() (err error) { return } + if keyBinding[binding.ContinuousEvaluation] == "false" { + if err = g.SetKeybinding("", gocui.KeyEnter, gocui.ModNone, ParseInput); err != nil { + return + } + } + Select(g, conflicts[cur], false) if err = g.MainLoop(); err != nil { diff --git a/prompt.go b/prompt.go index 27e472b..99e887e 100644 --- a/prompt.go +++ b/prompt.go @@ -85,6 +85,10 @@ func Evaluate(g *gocui.Gui, v *gocui.View, conf *conflict.Conflict, input string // It `evaluate`s the user's query and reflects the state on the UI func ParseInput(g *gocui.Gui, v *gocui.View) error { in := strings.TrimSuffix(v.Buffer(), "\n") + if keyBinding[binding.ContinuousEvaluation] == "false" { + v.Clear() + _ = v.SetCursor(0, 0) + } if err := Evaluate(g, v, conflicts[cur], in); err != nil { if err == ErrUnknownCmd { @@ -110,8 +114,8 @@ func PromptEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) { if keyBinding[binding.ContinuousEvaluation] == "true" { v.Clear() v.EditWrite(ch) - ParseInput(g, v) - v.SetCursor(0, 0) + _ = ParseInput(g, v) + _ = v.SetCursor(0, 0) } else { v.EditWrite(ch) } @@ -119,10 +123,6 @@ func PromptEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) { } switch key { - case gocui.KeyEnter: - ParseInput(g, v) - v.Clear() - v.SetCursor(0, 0) case gocui.KeySpace: v.EditWrite(' ') case gocui.KeyBackspace, gocui.KeyBackspace2: @@ -132,7 +132,7 @@ func PromptEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) { case gocui.KeyInsert: v.Overwrite = !v.Overwrite case gocui.KeyArrowDown: - v.SetCursor(len(v.Buffer())-1, 0) + _ = v.SetCursor(len(v.Buffer())-1, 0) case gocui.KeyArrowUp: v.MoveCursor(0, -1, false) case gocui.KeyArrowLeft: