mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
fix truncation
This commit is contained in:
@ -58,7 +58,6 @@ func TestGetPaddedDisplayStrings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestGetPadWidths is a function.
|
||||
func TestGetPadWidths(t *testing.T) {
|
||||
type scenario struct {
|
||||
input [][]string
|
||||
@ -91,3 +90,75 @@ func TestGetPadWidths(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncateWithEllipsis(t *testing.T) {
|
||||
// will need to check chinese characters as well
|
||||
// important that we have a three dot ellipsis within the limit
|
||||
type scenario struct {
|
||||
str string
|
||||
limit int
|
||||
expected string
|
||||
}
|
||||
|
||||
scenarios := []scenario{
|
||||
{
|
||||
"hello world !",
|
||||
1,
|
||||
".",
|
||||
},
|
||||
{
|
||||
"hello world !",
|
||||
2,
|
||||
"..",
|
||||
},
|
||||
{
|
||||
"hello world !",
|
||||
3,
|
||||
"...",
|
||||
},
|
||||
{
|
||||
"hello world !",
|
||||
4,
|
||||
"h...",
|
||||
},
|
||||
{
|
||||
"hello world !",
|
||||
5,
|
||||
"he...",
|
||||
},
|
||||
{
|
||||
"hello world !",
|
||||
12,
|
||||
"hello wor...",
|
||||
},
|
||||
{
|
||||
"hello world !",
|
||||
13,
|
||||
"hello world !",
|
||||
},
|
||||
{
|
||||
"hello world !",
|
||||
14,
|
||||
"hello world !",
|
||||
},
|
||||
{
|
||||
"大大大大",
|
||||
5,
|
||||
"大...",
|
||||
},
|
||||
{
|
||||
"大大大大",
|
||||
2,
|
||||
"..",
|
||||
},
|
||||
{
|
||||
"大大大大",
|
||||
0,
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
assert.EqualValues(t, s.expected, TruncateWithEllipsis(s.str, s.limit))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user