replace 3 dots with ellipsis (#3072)

Signed-off-by: charlie4284 <charlie4284@gmail.com>

Signed-off-by: charlie4284 <charlie4284@gmail.com>
This commit is contained in:
Yanks Yoon 2022-09-12 23:28:10 +08:00 committed by GitHub
parent 59476d4a1c
commit 3d624c0552
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -90,7 +90,7 @@ func Truncate(s string, n int) (string, bool) {
if n <= 3 {
return string(r[:n]), true
}
return string(r[:n-3]) + "...", true
return string(r[:n-1]) + "…", true
}
// TmplText is using monadic error handling in order to make string templating

View File

@ -46,7 +46,7 @@ func TestTruncate(t *testing.T) {
{
in: "abcde",
n: 4,
out: "a...",
out: "abc…",
trunc: true,
},
{
@ -58,7 +58,7 @@ func TestTruncate(t *testing.T) {
{
in: "abcdefgh",
n: 5,
out: "ab...",
out: "abcd…",
trunc: true,
},
{
@ -70,7 +70,7 @@ func TestTruncate(t *testing.T) {
{
in: "a⌘cdef",
n: 5,
out: "a⌘...",
out: "a⌘cd…",
trunc: true,
},
}