Skip to content

Commit 47786a3

Browse files
committed
fix(clue): truncate window title using final width
1 parent cc07c74 commit 47786a3

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

lua/mini/clue.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,8 +1710,8 @@ H.window_get_config = function()
17101710
end
17111711

17121712
-- Ensure proper config
1713+
res.width = math.min(math.max(res.width, 1), vim.o.columns - 2)
17131714
if type(res.title) == 'string' then res.title = H.fit_to_width(res.title, res.width) end
1714-
res.width = math.min(math.max(res.width, 1), vim.o.columns)
17151715

17161716
return res
17171717
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--|---------|---------|---------|---------|
2+
01|
3+
02|~
4+
03|~
5+
04|~
6+
05|~
7+
06|┌…opqrstuvwxyzabcdefgijklmnopqrstuvwxyz┐
8+
07|│ a │ LHS: " a" │
9+
08|└──────────────────────────────────────┘
10+
09|[No Name] 0,0-1
11+
10|
12+
13+
--|---------|---------|---------|---------|
14+
01|0000000000000000000000000000000000000000
15+
02|1111111111111111111111111111111111111111
16+
03|1111111111111111111111111111111111111111
17+
04|1111111111111111111111111111111111111111
18+
05|1111111111111111111111111111111111111111
19+
06|2333333333333333333333333333333333333332
20+
07|2444566666666666666666666666666666666662
21+
08|2222222222222222222222222222222222222222
22+
09|7777777777777777777777777777777777777777
23+
10|8888888888888888888888888888888888888888

tests/test_clue.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,15 @@ T['Showing keys']['respects `config.window.config`'] = function()
13101310

13111311
type_keys(' ')
13121312
child.expect_screenshot()
1313+
type_keys('<Esc>')
1314+
1315+
-- Should properly truncate title
1316+
child.lua([[
1317+
local title = string.sub('abcdefgijklmnopqrstuvwxyzabcdefgijklmnopqrstuvwxyz', -vim.o.columns)
1318+
MiniClue.config.window.config = { width = vim.o.columns, title = title }
1319+
]])
1320+
type_keys(' ')
1321+
child.expect_screenshot()
13131322
end
13141323

13151324
T['Showing keys']["respects 'winborder' option"] = function()

0 commit comments

Comments
 (0)