From 1febe66f846f500f4bd07fe14691e3b359f49c80 Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Thu, 17 Nov 2022 19:18:57 -0400 Subject: [PATCH] fix(readline): use uniseg to calculate width of virtual tab entry (closes #209) --- readline/tab-virtual.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/readline/tab-virtual.go b/readline/tab-virtual.go index fa7318e..d1e1d76 100644 --- a/readline/tab-virtual.go +++ b/readline/tab-virtual.go @@ -2,6 +2,7 @@ package readline import ( "strings" + "github.com/rivo/uniseg" ) // insertCandidateVirtual - When a completion candidate is selected, we insert it virtually in the input line: @@ -249,10 +250,10 @@ func (rl *Instance) viJumpEVirtual(tokeniser func([]rune, int) ([]string, int, i return case pos >= len(word)-1: word = rTrimWhiteSpace(split[index+1]) - adjust = len(split[index]) - pos - adjust += len(word) - 1 + adjust = uniseg.GraphemeClusterCount(split[index]) - pos + adjust += uniseg.GraphemeClusterCount(word) - 1 default: - adjust = len(word) - pos - 1 + adjust = uniseg.GraphemeClusterCount(word) - pos - 1 } return }