Revisión | cb50c26287e628f94a6c8c25e21e64e1c734ae7b (tree) |
---|---|
Tiempo | 2023-04-18 15:25:47 |
Autor | badcoff33 <none@none> |
Commiter | badcoff33 |
merged
@@ -0,0 +1,19 @@ | ||
1 | +vim9script | |
2 | + | |
3 | +export def TruncateString(str: string, max_len: number): string | |
4 | + if len(str) > max_len | |
5 | + return str[ : max_len - 1 ] .. ".." | |
6 | + else | |
7 | + return str | |
8 | + endif | |
9 | +enddef | |
10 | + | |
11 | +export def TruncateList(lst: list<string>, max_len: number): list<string> | |
12 | + var out = [] | |
13 | + for m in lst | |
14 | + add(out, TruncateString(m, max_len)) | |
15 | + endfor | |
16 | + return out | |
17 | +enddef | |
18 | + | |
19 | + |