From ff6f28e36663a10db7d52e75f2a512347949728f Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Wed, 25 Dec 2019 13:11:38 -0500 Subject: [PATCH] Autocompletion fix for infobuffer --- internal/action/actions.go | 4 ++-- internal/action/infopane.go | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/internal/action/actions.go b/internal/action/actions.go index 585646a3..48a2cd27 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -1386,8 +1386,8 @@ func (h *BufPane) PlayMacro() bool { switch t := action.(type) { case rune: h.DoRuneInsert(t) - case Event: - h.DoKeyEvent(t) + case func(*BufPane) bool: + t(h) } } h.Relocate() diff --git a/internal/action/infopane.go b/internal/action/infopane.go index cc0ef609..33b40268 100644 --- a/internal/action/infopane.go +++ b/internal/action/infopane.go @@ -2,6 +2,7 @@ package action import ( "bytes" + "strings" "github.com/zyedidia/micro/internal/display" "github.com/zyedidia/micro/internal/info" @@ -82,7 +83,9 @@ func (h *InfoPane) DoKeyEvent(e KeyEvent) bool { } } for s, a := range InfoOverrides { - if s == estr { + // TODO this is a hack and really we should have support + // for having binding overrides for different buffers + if strings.Contains(estr, s) { done = true a(h) break @@ -150,7 +153,7 @@ var InfoOverrides = map[string]InfoKeyAction{ "CursorUp": (*InfoPane).CursorUp, "CursorDown": (*InfoPane).CursorDown, "InsertNewline": (*InfoPane).InsertNewline, - "InsertTab": (*InfoPane).InsertTab, + "Autocomplete": (*InfoPane).Autocomplete, "OutdentLine": (*InfoPane).CycleBack, "Escape": (*InfoPane).Escape, "Quit": (*InfoPane).Quit, @@ -167,8 +170,8 @@ func (h *InfoPane) CursorDown() { h.DownHistory(h.History[h.PromptType]) } -// InsertTab begins autocompletion -func (h *InfoPane) InsertTab() { +// Autocomplete begins autocompletion +func (h *InfoPane) Autocomplete() { b := h.Buf if b.HasSuggestions { b.CycleAutocomplete(true)