2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-03-13 18:00:41 +00:00

feat: select 1st item on history find menu (closes #148)

cancels on escape unless the user moves to another item
This commit is contained in:
TorchedSammy 2022-11-25 20:14:29 -04:00
parent ebec585690
commit bd4e0df7b3
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD

View File

@ -333,6 +333,8 @@ func (rl *Instance) Readline() (string, error) {
rl.modeTabFind = true rl.modeTabFind = true
rl.updateTabFind([]rune{}) rl.updateTabFind([]rune{})
rl.updateVirtualComp()
rl.renderHelpers()
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true
// Tab Completion & Completion Search --------------------------------------------------------------- // Tab Completion & Completion Search ---------------------------------------------------------------
@ -486,7 +488,10 @@ func (rl *Instance) Readline() (string, error) {
if string(r[:i]) != seqShiftTab && if string(r[:i]) != seqShiftTab &&
string(r[:i]) != seqForwards && string(r[:i]) != seqBackwards && string(r[:i]) != seqForwards && string(r[:i]) != seqBackwards &&
string(r[:i]) != seqUp && string(r[:i]) != seqDown { string(r[:i]) != seqUp && string(r[:i]) != seqDown {
rl.resetVirtualComp(false) // basically only applies except on 1st ctrl r open
// so if we have not explicitly selected something
// (tabCompletionSelect is false) drop virtual completion
rl.resetVirtualComp(!rl.tabCompletionSelect)
} }
} }
@ -608,6 +613,7 @@ func (rl *Instance) escapeSeq(r []rune) {
case string(charEscape): case string(charEscape):
switch { switch {
case rl.modeAutoFind: case rl.modeAutoFind:
rl.resetVirtualComp(true)
rl.resetTabFind() rl.resetTabFind()
rl.clearHelpers() rl.clearHelpers()
rl.resetTabCompletion() rl.resetTabCompletion()
@ -615,6 +621,7 @@ func (rl *Instance) escapeSeq(r []rune) {
rl.renderHelpers() rl.renderHelpers()
case rl.modeTabFind: case rl.modeTabFind:
rl.resetVirtualComp(true)
rl.resetTabFind() rl.resetTabFind()
rl.resetTabCompletion() rl.resetTabCompletion()