diff --git a/readline/comp-map.go b/readline/comp-map.go index ec985ff..ca444d4 100644 --- a/readline/comp-map.go +++ b/readline/comp-map.go @@ -121,6 +121,7 @@ func (g *CompletionGroup) writeMap(rl *Instance) (comp string) { } description = g.Descriptions[g.Suggestions[i]] + rl.lineCompDescription = description if len(description) > maxLength { description = description[:maxLength-3] + "..." } diff --git a/readline/instance.go b/readline/instance.go index a477246..0af4dd3 100644 --- a/readline/instance.go +++ b/readline/instance.go @@ -101,6 +101,7 @@ type Instance struct { // Candidate / virtual completion string / etc currentComp []rune // The currently selected item, not yet a real part of the input line. lineComp []rune // Same as rl.line, but with the currentComp inserted. + lineCompDescription string lineRemain []rune // When we complete in the middle of a line, we cut and keep the remain. compAddSpace bool // If true, any candidate inserted into the real line is done with an added space. diff --git a/readline/readline.go b/readline/readline.go index 54713a6..36dc466 100644 --- a/readline/readline.go +++ b/readline/readline.go @@ -6,7 +6,10 @@ import ( "fmt" "os" "regexp" + "strconv" "syscall" + + ansi "github.com/acarl005/stripansi" ) var rxMultiline = regexp.MustCompile(`[\r\n]+`) @@ -838,10 +841,12 @@ func (rl *Instance) escapeSeq(r []rune) { case seqCtrlDelete, seqCtrlDelete2, seqAltD: if rl.searchMode == HistoryFind { - fmt.Println("\nCURRENT COMP\n", string(rl.lineComp), "\n\n\n") - rl.resetVirtualComp(true) + idx, err := strconv.Atoi(ansi.Strip(rl.lineCompDescription)) + fmt.Println("\nCURRENT COMP\n", string(rl.lineComp), idx, "\n\n\n") + fmt.Println(idx, err) + rl.updateVirtualComp() - rl.renderHelpers() + rl.updateHelpers() rl.viUndoSkipAppend = true return }