From bc7b70fefe7e9863cd7982f80344594943f6b40b Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Wed, 2 Jan 2019 20:57:27 -0500 Subject: [PATCH] Fix infobar prompt --- cmd/micro/action/actions.go | 4 ++-- cmd/micro/action/command.go | 2 +- cmd/micro/info/infobuffer.go | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/micro/action/actions.go b/cmd/micro/action/actions.go index 425142dd..60722813 100644 --- a/cmd/micro/action/actions.go +++ b/cmd/micro/action/actions.go @@ -725,7 +725,7 @@ func (h *BufHandler) SelectAll() bool { // OpenFile opens a new file in the buffer func (h *BufHandler) OpenFile() bool { - InfoBar.Prompt("> open ", func(resp string, canceled bool) { + InfoBar.Prompt("> ", "open ", func(resp string, canceled bool) { if !canceled { HandleCommand(resp) } @@ -889,7 +889,7 @@ func (h *BufHandler) ShellMode() bool { // CommandMode lets the user enter a command func (h *BufHandler) CommandMode() bool { - InfoBar.Prompt("> ", func(resp string, canceled bool) { + InfoBar.Prompt("> ", "", func(resp string, canceled bool) { if !canceled { HandleCommand(resp) } diff --git a/cmd/micro/action/command.go b/cmd/micro/action/command.go index a4c28c2c..62a1a73b 100644 --- a/cmd/micro/action/command.go +++ b/cmd/micro/action/command.go @@ -119,7 +119,7 @@ func DefaultCommands() map[string]StrCommand { // enter func CommandEditAction(prompt string) BufKeyAction { return func(h *BufHandler) bool { - InfoBar.Prompt("> "+prompt, func(resp string, canceled bool) { + InfoBar.Prompt("> ", prompt, func(resp string, canceled bool) { if !canceled { HandleCommand(resp) } diff --git a/cmd/micro/info/infobuffer.go b/cmd/micro/info/infobuffer.go index c7360711..6e670305 100644 --- a/cmd/micro/info/infobuffer.go +++ b/cmd/micro/info/infobuffer.go @@ -62,16 +62,17 @@ func (i *InfoBuf) Error(msg ...interface{}) { // TODO: add to log? } -func (i *InfoBuf) Prompt(msg string, callback func(string, bool)) { +func (i *InfoBuf) Prompt(prompt string, msg string, callback func(string, bool)) { // If we get another prompt mid-prompt we cancel the one getting overwritten if i.HasPrompt { i.DonePrompt(true) } - i.Msg = msg + i.Msg = prompt i.HasPrompt = true i.HasMessage, i.HasError = false, false i.PromptCallback = callback + i.Buffer.Insert(i.Buffer.Start(), msg) } func (i *InfoBuf) DonePrompt(canceled bool) {