mirror of https://github.com/Hilbis/Hilbish
feat: store current idx of history search
parent
504e9b272a
commit
856d3197d1
|
@ -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] + "..."
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue