mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-01 21:50:28 +08:00
Fix coloring of items with zero-width characters
This commit fixes incorrect coloring for items that contain zero-width characters. It also makes ellipsis coloring consistent when text is trimmed from either the left or the right. Fix #4620 Close #4646
This commit is contained in:
+6
-1
@@ -18,8 +18,13 @@ func StringWidth(s string) int {
|
||||
|
||||
// RunesWidth returns runes width
|
||||
func RunesWidth(runes []rune, prefixWidth int, tabstop int, limit int) (int, int) {
|
||||
return StringsWidth(string(runes), prefixWidth, tabstop, limit)
|
||||
}
|
||||
|
||||
// StringsWidth returns the width of the string
|
||||
func StringsWidth(str string, prefixWidth int, tabstop int, limit int) (int, int) {
|
||||
width := 0
|
||||
gr := uniseg.NewGraphemes(string(runes))
|
||||
gr := uniseg.NewGraphemes(str)
|
||||
idx := 0
|
||||
for gr.Next() {
|
||||
rs := gr.Runes()
|
||||
|
||||
Reference in New Issue
Block a user