fix: only remove prefix if not in history find mode

insensitive-tab-2
TorchedSammy 2022-12-05 17:55:43 -04:00
parent b9364bd8b4
commit 4e40bc57e0
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 8 additions and 2 deletions

View File

@ -75,6 +75,7 @@ func (rl *Instance) insertCandidate() {
// Ensure no indexing error happens with prefix // Ensure no indexing error happens with prefix
if len(completion) >= prefix { if len(completion) >= prefix {
rl.viDeleteByAdjust(-prefix) rl.viDeleteByAdjust(-prefix)
rl.insert([]rune(completion)) rl.insert([]rune(completion))
if !cur.TrimSlash && !cur.NoSpace { if !cur.TrimSlash && !cur.NoSpace {
rl.insert([]rune(" ")) rl.insert([]rune(" "))
@ -99,7 +100,7 @@ func (rl *Instance) updateVirtualComp() {
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true
rl.resetTabCompletion() rl.resetTabCompletion()
} else { } else {
if strings.HasSuffix(string(rl.line), rl.tcPrefix) { if strings.HasSuffix(string(rl.line), rl.tcPrefix) && (!rl.modeAutoFind || rl.searchMode != HistoryFind) {
rl.viDeleteByAdjust(-prefix) rl.viDeleteByAdjust(-prefix)
} }
@ -112,7 +113,12 @@ func (rl *Instance) updateVirtualComp() {
// Or insert it virtually. // Or insert it virtually.
if len(completion) >= prefix { if len(completion) >= prefix {
rl.insertCandidateVirtual([]rune(completion)) comp := completion
if rl.modeAutoFind && rl.searchMode == HistoryFind {
comp = completion[prefix:]
}
rl.insertCandidateVirtual([]rune(comp))
} }
} }
} }