m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-19 00:53:42 -05:00

Fix rendering of the prompt line when overflow occurs with --info=inline

Fix #2692
This commit is contained in:
Junegunn Choi
2021-12-22 23:22:08 +09:00
parent 176ee6910f
commit cd23401411
4 changed files with 21 additions and 3 deletions

View File

@@ -26,7 +26,7 @@ func RunesWidth(runes []rune, prefixWidth int, tabstop int, limit int) (int, int
w = runewidth.StringWidth(s) + strings.Count(s, "\n")
}
width += w
if limit > 0 && width > limit {
if width > limit {
return width, idx
}
idx += len(rs)

View File

@@ -38,3 +38,19 @@ func TestOnce(t *testing.T) {
t.Error("Expected: false")
}
}
func TestRunesWidth(t *testing.T) {
for _, args := range [][]int{
{100, 5, -1},
{3, 4, 3},
{0, 1, 0},
} {
width, overflowIdx := RunesWidth([]rune("hello"), 0, 0, args[0])
if width != args[1] {
t.Errorf("Expected width: %d, actual: %d", args[1], width)
}
if overflowIdx != args[2] {
t.Errorf("Expected overflow index: %d, actual: %d", args[2], overflowIdx)
}
}
}