Autocompletion fix for infobuffer

This commit is contained in:
Zachary Yedidia 2019-12-25 13:11:38 -05:00
parent 4951f155ea
commit ff6f28e366
2 changed files with 9 additions and 6 deletions

View file

@ -1386,8 +1386,8 @@ func (h *BufPane) PlayMacro() bool {
switch t := action.(type) { switch t := action.(type) {
case rune: case rune:
h.DoRuneInsert(t) h.DoRuneInsert(t)
case Event: case func(*BufPane) bool:
h.DoKeyEvent(t) t(h)
} }
} }
h.Relocate() h.Relocate()

View file

@ -2,6 +2,7 @@ package action
import ( import (
"bytes" "bytes"
"strings"
"github.com/zyedidia/micro/internal/display" "github.com/zyedidia/micro/internal/display"
"github.com/zyedidia/micro/internal/info" "github.com/zyedidia/micro/internal/info"
@ -82,7 +83,9 @@ func (h *InfoPane) DoKeyEvent(e KeyEvent) bool {
} }
} }
for s, a := range InfoOverrides { 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 done = true
a(h) a(h)
break break
@ -150,7 +153,7 @@ var InfoOverrides = map[string]InfoKeyAction{
"CursorUp": (*InfoPane).CursorUp, "CursorUp": (*InfoPane).CursorUp,
"CursorDown": (*InfoPane).CursorDown, "CursorDown": (*InfoPane).CursorDown,
"InsertNewline": (*InfoPane).InsertNewline, "InsertNewline": (*InfoPane).InsertNewline,
"InsertTab": (*InfoPane).InsertTab, "Autocomplete": (*InfoPane).Autocomplete,
"OutdentLine": (*InfoPane).CycleBack, "OutdentLine": (*InfoPane).CycleBack,
"Escape": (*InfoPane).Escape, "Escape": (*InfoPane).Escape,
"Quit": (*InfoPane).Quit, "Quit": (*InfoPane).Quit,
@ -167,8 +170,8 @@ func (h *InfoPane) CursorDown() {
h.DownHistory(h.History[h.PromptType]) h.DownHistory(h.History[h.PromptType])
} }
// InsertTab begins autocompletion // Autocomplete begins autocompletion
func (h *InfoPane) InsertTab() { func (h *InfoPane) Autocomplete() {
b := h.Buf b := h.Buf
if b.HasSuggestions { if b.HasSuggestions {
b.CycleAutocomplete(true) b.CycleAutocomplete(true)