From 1339dc4a2f2e1ecfca4289f799631ab2cd337769 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sat, 28 May 2022 21:05:03 -0400 Subject: [PATCH] fix: multiline cursor redraw --- readline/line.go | 1 + readline/prompt.go | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/readline/line.go b/readline/line.go index 974a34d..3dfa7c4 100644 --- a/readline/line.go +++ b/readline/line.go @@ -45,6 +45,7 @@ func (rl *Instance) echo() { print(seqClearScreenBelow) // Print the prompt + rl.promptInPlace("") print(string(rl.realPrompt)) // Assemble the line, taking virtual completions into account diff --git a/readline/prompt.go b/readline/prompt.go index 699abec..abda175 100644 --- a/readline/prompt.go +++ b/readline/prompt.go @@ -73,8 +73,7 @@ func (rl *Instance) RefreshPromptLog(log string) (err error) { return } -// RefreshPromptInPlace - Refreshes the prompt in the very same place he is. -func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) { +func (rl *Instance) promptInPlace(prompt string) { // We adjust cursor movement, depending on which mode we're currently in. // Prompt data intependent if !rl.modeTabCompletion { @@ -91,15 +90,11 @@ func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) { rl.SetPrompt(prompt) } - if rl.Multiline { - rl.tcUsedY += 1 - } - // Clear the input line and everything below print(seqClearLine) moveCursorUp(rl.infoY + rl.tcUsedY) moveCursorBackwards(GetTermWidth()) - print("\r\n" + seqClearScreenBelow) + print("\r" + seqClearScreenBelow) // Add a new line if needed if rl.Multiline { @@ -108,8 +103,11 @@ func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) { } else { fmt.Print(rl.mainPrompt) } +} - // Refresh the line +// RefreshPromptInPlace - Refreshes the prompt in the very same place he is. +func (rl *Instance) RefreshPromptInPlace(prompt string) (err error) { + rl.promptInPlace(prompt) rl.updateHelpers() return