Add cycleautocompleteback action

This commit is contained in:
Zachary Yedidia
2020-01-04 15:51:15 -05:00
parent c2c0325384
commit d234e9ec41
4 changed files with 19 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
package action
import (
"log"
"regexp"
"runtime"
"strings"
@@ -611,6 +612,21 @@ func (h *BufPane) Autocomplete() bool {
return b.Autocomplete(buffer.BufferComplete)
}
// CycleAutocompleteBack cycles back in the autocomplete suggestion list
func (h *BufPane) CycleAutocompleteBack() bool {
if h.Cursor.HasSelection() {
return false
}
log.Println(h.Buf.HasSuggestions)
if h.Buf.HasSuggestions {
h.Buf.CycleAutocomplete(false)
log.Println("TRUE")
return true
}
return false
}
// InsertTab inserts a tab or spaces
func (h *BufPane) InsertTab() bool {
b := h.Buf

View File

@@ -422,7 +422,7 @@ func DefaultBindings() map[string]string {
"Alt-CtrlH": "DeleteWordLeft",
"Alt-Backspace": "DeleteWordLeft",
"Tab": "Autocomplete|IndentSelection|InsertTab",
"Backtab": "OutdentSelection|OutdentLine",
"Backtab": "CycleAutocompleteBack|OutdentSelection|OutdentLine",
"CtrlO": "OpenFile",
"CtrlS": "Save",
"CtrlF": "Find",

View File

@@ -355,7 +355,7 @@ func (h *BufPane) DoKeyEvent(e Event) bool {
}
func (h *BufPane) execAction(action func(*BufPane) bool, name string, cursor int) bool {
if name != "Autocomplete" {
if name != "Autocomplete" && name != "CycleAutocompleteBack" {
h.Buf.HasSuggestions = false
}
@@ -523,6 +523,7 @@ var BufKeyActions = map[string]BufKeyAction{
"IndentSelection": (*BufPane).IndentSelection,
"OutdentSelection": (*BufPane).OutdentSelection,
"Autocomplete": (*BufPane).Autocomplete,
"CycleAutocompleteBack": (*BufPane).CycleAutocompleteBack,
"OutdentLine": (*BufPane).OutdentLine,
"Paste": (*BufPane).Paste,
"PastePrimary": (*BufPane).PastePrimary,

View File

@@ -154,7 +154,6 @@ var InfoOverrides = map[string]InfoKeyAction{
"CursorDown": (*InfoPane).CursorDown,
"InsertNewline": (*InfoPane).InsertNewline,
"Autocomplete": (*InfoPane).Autocomplete,
"OutdentLine": (*InfoPane).CycleBack,
"Escape": (*InfoPane).Escape,
"Quit": (*InfoPane).Quit,
"QuitAll": (*InfoPane).QuitAll,
@@ -196,13 +195,6 @@ func (h *InfoPane) Autocomplete() {
}
}
// CycleBack cycles back in the autocomplete suggestion list
func (h *InfoPane) CycleBack() {
if h.Buf.HasSuggestions {
h.Buf.CycleAutocomplete(false)
}
}
// InsertNewline completes the prompt
func (h *InfoPane) InsertNewline() {
if !h.HasYN {