fix(readline): use uniseg to calculate width of virtual tab entry (closes #209)

pull/312/head
TorchedSammy 2022-11-17 19:18:57 -04:00
parent 6ffcc498ac
commit 1febe66f84
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 4 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package readline
import ( import (
"strings" "strings"
"github.com/rivo/uniseg"
) )
// insertCandidateVirtual - When a completion candidate is selected, we insert it virtually in the input line: // 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 return
case pos >= len(word)-1: case pos >= len(word)-1:
word = rTrimWhiteSpace(split[index+1]) word = rTrimWhiteSpace(split[index+1])
adjust = len(split[index]) - pos adjust = uniseg.GraphemeClusterCount(split[index]) - pos
adjust += len(word) - 1 adjust += uniseg.GraphemeClusterCount(word) - 1
default: default:
adjust = len(word) - pos - 1 adjust = uniseg.GraphemeClusterCount(word) - pos - 1
} }
return return
} }