Skip to content

Commit

Permalink
(mini.notify) Add window refresh on instance resize.
Browse files Browse the repository at this point in the history
  • Loading branch information
echasnovski committed Jan 27, 2024
1 parent 1cd8d7e commit 4fc7c1e
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/mini/notify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ H.create_autocommands = function(config)
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
end

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

--stylua: ignore
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--|---------|---------|---------|---------|---------|
01| ┌───────────────────┐
02|~ │12:34:56 │ A very l│
03|~ │ong notification │
04|~ └───────────────────┘
05|~
06|~
07|~
08|~
09|~
10|

--|---------|---------|---------|---------|---------|
01|00000000000000000000000000000111111111111111111111
02|22222222222222222222222222222133333333333333333331
03|22222222222222222222222222222133333333333333333331
04|22222222222222222222222222222111111111111111111111
05|22222222222222222222222222222222222222222222222222
06|22222222222222222222222222222222222222222222222222
07|22222222222222222222222222222222222222222222222222
08|22222222222222222222222222222222222222222222222222
09|22222222222222222222222222222222222222222222222222
10|44444444444444444444444444444444444444444444444444
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--|---------|---------|-----
01| ┌─────────┐
02|~ │12:34:56 │
03|~ ││ A very │
04|~ │long noti│
05|~ │fication │
06|~ └─────────┘
07|~
08|~
09|~
10|

--|---------|---------|-----
01|0000000000000011111111111
02|2222222222222213333333331
03|2222222222222213333333331
04|2222222222222213333333331
05|2222222222222213333333331
06|2222222222222211111111111
07|2222222222222222222222222
08|2222222222222222222222222
09|2222222222222222222222222
10|4444444444444444444444444
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--|---------|---------|---------|---------|---------|
01|
02|~
03|~
04|~ ┌───────────────────┐
05|~ │12:34:58 │ A very l│
06|~ │ong notification │
07|~ └───────────────────┘
08|~
09|~
10|~
11|~
12|~
13|~
14|~
15|

--|---------|---------|---------|---------|---------|
01|00000000000000000000000000000000000000000000000000
02|11111111111111111111111111111111111111111111111111
03|11111111111111111111111111111111111111111111111111
04|11111111111111111112222222222222222222221111111111
05|11111111111111111112333333333333333333321111111111
06|11111111111111111112333333333333333333321111111111
07|11111111111111111112222222222222222222221111111111
08|11111111111111111111111111111111111111111111111111
09|11111111111111111111111111111111111111111111111111
10|11111111111111111111111111111111111111111111111111
11|11111111111111111111111111111111111111111111111111
12|11111111111111111111111111111111111111111111111111
13|11111111111111111111111111111111111111111111111111
14|11111111111111111111111111111111111111111111111111
15|44444444444444444444444444444444444444444444444444
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--|---------|---------|-----
01|
02|~
03|~ ┌─────────┐
04|~ │12:34:58 │
05|~ ││ A very │
06|~ │long noti│
07|~ │fication │
08|~ └─────────┘
09|~
10|

--|---------|---------|-----
01|0000000000000000000000000
02|1111111111111111111111111
03|1111111112222222222211111
04|1111111112333333333211111
05|1111111112333333333211111
06|1111111112333333333211111
07|1111111112333333333211111
08|1111111112222222222211111
09|1111111111111111111111111
10|4444444444444444444444444
20 changes: 20 additions & 0 deletions tests/test_notify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,26 @@ T['Window']['persists across tabpages'] = function()
eq(is_notif_window_shown(new_tabpage_id), false)
end

T['Window']['fully updates on vim resize'] = function()
-- With default window config
child.set_size(10, 50)
add('A very long notification')
child.expect_screenshot()
child.o.columns = 25
child.expect_screenshot()
clear()

-- With callable window config
child.set_size(15, 50)
child.lua([[MiniNotify.config.window.config = function()
return { row = math.floor(0.2 * vim.o.lines), col = math.floor(0.8 * vim.o.columns) }
end]])
add('A very long notification')
child.expect_screenshot()
child.o.lines, child.o.columns = 10, 25
child.expect_screenshot()
end

T['Window']['does not affect normal window navigation'] = function()
local win_id_1 = child.api.nvim_get_current_win()
child.cmd('botright wincmd v')
Expand Down

0 comments on commit 4fc7c1e

Please sign in to comment.