From b311f24b3f037df791734d3a06edee085a15da01 Mon Sep 17 00:00:00 2001 From: sammyette Date: Sun, 22 Dec 2024 12:07:23 -0400 Subject: [PATCH] refactor: move hint insert to function --- readline/hint.go | 7 +++++++ readline/readline.go | 6 ++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/readline/hint.go b/readline/hint.go index 6c6a67c..d0c54fe 100644 --- a/readline/hint.go +++ b/readline/hint.go @@ -56,3 +56,10 @@ func (rl *Instance) resetHintText() { //rl.hintY = 0 rl.hintText = []rune{} } + +func (rl *Instance) insertHintText() { + if len(rl.hintText) != 0 { + // fill in hint text + rl.insert(rl.hintText) + } +} diff --git a/readline/readline.go b/readline/readline.go index f79f165..7282071 100644 --- a/readline/readline.go +++ b/readline/readline.go @@ -708,10 +708,8 @@ func (rl *Instance) escapeSeq(r []rune) { return } - if len(rl.hintText) != 0 { - // fill in hint text - rl.insert(rl.hintText) - } + rl.insertHintText() + if (rl.modeViMode == VimInsert && rl.pos < len(rl.line)) || (rl.modeViMode != VimInsert && rl.pos < len(rl.line)-1) { rl.moveCursorByAdjust(1)