fix: don't refetch tab completion on refresh if its already open (closes #163)

lazy-interfaces
TorchedSammy 2022-05-31 15:16:32 -04:00
parent 9d385efbfc
commit 3196f0dcb9
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
4 changed files with 6 additions and 4 deletions

View File

@ -96,6 +96,7 @@ type Instance struct {
tabCompletionSelect bool // We may have completions printed, but no selected candidate yet
tabCompletionReverse bool // Groups sometimes use this indicator to know how they should handle their index
tcUsedY int // Comprehensive offset of the currently built completions
completionOpen bool
// Candidate / virtual completion string / etc
currentComp []rune // The currently selected item, not yet a real part of the input line.

View File

@ -79,9 +79,8 @@ func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) {
// Prompt data intependent
if !rl.modeTabCompletion {
rl.tcUsedY = 1
// Account for the info line
} else if rl.modeTabCompletion && rl.modeAutoFind {
rl.tcUsedY = 0
rl.tcUsedY = -1 // idk man
} else {
rl.tcUsedY = 1
}

View File

@ -215,7 +215,7 @@ func (rl *Instance) getCompletions() {
// moveTabCompletionHighlight - This function is in charge of
// computing the new position in the current completions liste.
func (rl *Instance) moveTabCompletionHighlight(x, y int) {
rl.completionOpen = true
g := rl.getCurrentGroup()
// If there is no current group, we leave any current completion mode.

View File

@ -11,8 +11,10 @@ func (rl *Instance) updateHelpers() {
// Thus overwrites anything having been dirtily added/forced/modified, like rl.SetInfoText()
rl.getInfoText()
rl.getHintText()
if rl.modeTabCompletion {
if rl.modeTabCompletion && !rl.completionOpen {
rl.getTabCompletion()
} else {
if rl.completionOpen { rl.completionOpen = false }
}
// We clear everything