From 3196f0dcb93c1de089e6681553d822f6a98c45ce Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Tue, 31 May 2022 15:16:32 -0400 Subject: [PATCH] fix: don't refetch tab completion on refresh if its already open (closes #163) --- readline/instance.go | 1 + readline/prompt.go | 3 +-- readline/tab.go | 2 +- readline/update.go | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/readline/instance.go b/readline/instance.go index ec6b861..f04811e 100644 --- a/readline/instance.go +++ b/readline/instance.go @@ -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. diff --git a/readline/prompt.go b/readline/prompt.go index 699abec..79f7c71 100644 --- a/readline/prompt.go +++ b/readline/prompt.go @@ -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 } diff --git a/readline/tab.go b/readline/tab.go index c3f9c37..e6522e6 100644 --- a/readline/tab.go +++ b/readline/tab.go @@ -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. diff --git a/readline/update.go b/readline/update.go index 508ae24..0c2de38 100644 --- a/readline/update.go +++ b/readline/update.go @@ -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