From 4e40bc57e0591a236eda628017ab7413721325a7 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:55:43 -0400 Subject: [PATCH] fix: only remove prefix if not in history find mode --- readline/tab-virtual.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/readline/tab-virtual.go b/readline/tab-virtual.go index a44db8b..37df4d5 100644 --- a/readline/tab-virtual.go +++ b/readline/tab-virtual.go @@ -75,6 +75,7 @@ func (rl *Instance) insertCandidate() { // Ensure no indexing error happens with prefix if len(completion) >= prefix { rl.viDeleteByAdjust(-prefix) + rl.insert([]rune(completion)) if !cur.TrimSlash && !cur.NoSpace { rl.insert([]rune(" ")) @@ -99,7 +100,7 @@ func (rl *Instance) updateVirtualComp() { rl.viUndoSkipAppend = true rl.resetTabCompletion() } 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) } @@ -112,7 +113,12 @@ func (rl *Instance) updateVirtualComp() { // Or insert it virtually. if len(completion) >= prefix { - rl.insertCandidateVirtual([]rune(completion)) + comp := completion + if rl.modeAutoFind && rl.searchMode == HistoryFind { + comp = completion[prefix:] + } + + rl.insertCandidateVirtual([]rune(comp)) } } }