Skip to content

Commit 4fc7c1e

Browse files
committed
(mini.notify) Add window refresh on instance resize.
1 parent 1cd8d7e commit 4fc7c1e

6 files changed

+123
-1
lines changed

lua/mini/notify.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ H.create_autocommands = function(config)
582582
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
583583
end
584584

585-
au('TabEnter', '*', function() MiniNotify.refresh() end, 'Refresh in notifications in new tabpage')
585+
au({ 'TabEnter', 'VimResized' }, '*', function() MiniNotify.refresh() end, 'Refresh notifications')
586586
end
587587

588588
--stylua: ignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--|---------|---------|---------|---------|---------|
2+
01| ┌───────────────────┐
3+
02|~ │12:34:56 │ A very l│
4+
03|~ │ong notification │
5+
04|~ └───────────────────┘
6+
05|~
7+
06|~
8+
07|~
9+
08|~
10+
09|~
11+
10|
12+
13+
--|---------|---------|---------|---------|---------|
14+
01|00000000000000000000000000000111111111111111111111
15+
02|22222222222222222222222222222133333333333333333331
16+
03|22222222222222222222222222222133333333333333333331
17+
04|22222222222222222222222222222111111111111111111111
18+
05|22222222222222222222222222222222222222222222222222
19+
06|22222222222222222222222222222222222222222222222222
20+
07|22222222222222222222222222222222222222222222222222
21+
08|22222222222222222222222222222222222222222222222222
22+
09|22222222222222222222222222222222222222222222222222
23+
10|44444444444444444444444444444444444444444444444444
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--|---------|---------|-----
2+
01| ┌─────────┐
3+
02|~ │12:34:56 │
4+
03|~ ││ A very │
5+
04|~ │long noti│
6+
05|~ │fication │
7+
06|~ └─────────┘
8+
07|~
9+
08|~
10+
09|~
11+
10|
12+
13+
--|---------|---------|-----
14+
01|0000000000000011111111111
15+
02|2222222222222213333333331
16+
03|2222222222222213333333331
17+
04|2222222222222213333333331
18+
05|2222222222222213333333331
19+
06|2222222222222211111111111
20+
07|2222222222222222222222222
21+
08|2222222222222222222222222
22+
09|2222222222222222222222222
23+
10|4444444444444444444444444
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--|---------|---------|---------|---------|---------|
2+
01|
3+
02|~
4+
03|~
5+
04|~ ┌───────────────────┐
6+
05|~ │12:34:58 │ A very l│
7+
06|~ │ong notification │
8+
07|~ └───────────────────┘
9+
08|~
10+
09|~
11+
10|~
12+
11|~
13+
12|~
14+
13|~
15+
14|~
16+
15|
17+
18+
--|---------|---------|---------|---------|---------|
19+
01|00000000000000000000000000000000000000000000000000
20+
02|11111111111111111111111111111111111111111111111111
21+
03|11111111111111111111111111111111111111111111111111
22+
04|11111111111111111112222222222222222222221111111111
23+
05|11111111111111111112333333333333333333321111111111
24+
06|11111111111111111112333333333333333333321111111111
25+
07|11111111111111111112222222222222222222221111111111
26+
08|11111111111111111111111111111111111111111111111111
27+
09|11111111111111111111111111111111111111111111111111
28+
10|11111111111111111111111111111111111111111111111111
29+
11|11111111111111111111111111111111111111111111111111
30+
12|11111111111111111111111111111111111111111111111111
31+
13|11111111111111111111111111111111111111111111111111
32+
14|11111111111111111111111111111111111111111111111111
33+
15|44444444444444444444444444444444444444444444444444
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--|---------|---------|-----
2+
01|
3+
02|~
4+
03|~ ┌─────────┐
5+
04|~ │12:34:58 │
6+
05|~ ││ A very │
7+
06|~ │long noti│
8+
07|~ │fication │
9+
08|~ └─────────┘
10+
09|~
11+
10|
12+
13+
--|---------|---------|-----
14+
01|0000000000000000000000000
15+
02|1111111111111111111111111
16+
03|1111111112222222222211111
17+
04|1111111112333333333211111
18+
05|1111111112333333333211111
19+
06|1111111112333333333211111
20+
07|1111111112333333333211111
21+
08|1111111112222222222211111
22+
09|1111111111111111111111111
23+
10|4444444444444444444444444

tests/test_notify.lua

+20
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,26 @@ T['Window']['persists across tabpages'] = function()
831831
eq(is_notif_window_shown(new_tabpage_id), false)
832832
end
833833

834+
T['Window']['fully updates on vim resize'] = function()
835+
-- With default window config
836+
child.set_size(10, 50)
837+
add('A very long notification')
838+
child.expect_screenshot()
839+
child.o.columns = 25
840+
child.expect_screenshot()
841+
clear()
842+
843+
-- With callable window config
844+
child.set_size(15, 50)
845+
child.lua([[MiniNotify.config.window.config = function()
846+
return { row = math.floor(0.2 * vim.o.lines), col = math.floor(0.8 * vim.o.columns) }
847+
end]])
848+
add('A very long notification')
849+
child.expect_screenshot()
850+
child.o.lines, child.o.columns = 10, 25
851+
child.expect_screenshot()
852+
end
853+
834854
T['Window']['does not affect normal window navigation'] = function()
835855
local win_id_1 = child.api.nvim_get_current_win()
836856
child.cmd('botright wincmd v')

0 commit comments

Comments
 (0)