mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
Notify attached UIs whenever menus change
This adds a redraw notification "update_menu" which is sent whenever Vim's menus are changed by the :menu command and friends.
This commit is contained in:
52
test/functional/api/menu_spec.lua
Normal file
52
test/functional/api/menu_spec.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
local helpers = require('test.functional.helpers')
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local feed = helpers.feed
|
||||
|
||||
describe("update_menu notification", function()
|
||||
|
||||
local screen
|
||||
|
||||
before_each(function()
|
||||
clear()
|
||||
screen = Screen.new()
|
||||
screen:attach()
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
screen:detach()
|
||||
end)
|
||||
|
||||
function expect_sent(expected)
|
||||
screen:wait(function()
|
||||
if screen.update_menu ~= expected then
|
||||
if expected then
|
||||
return 'update_menu was expected but not sent'
|
||||
else
|
||||
return 'update_menu was sent unexpectedly'
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
it("should be sent when adding a menu", function()
|
||||
command('menu Test.Test :')
|
||||
expect_sent(true)
|
||||
end)
|
||||
|
||||
it("should be sent when deleting a menu", function()
|
||||
command('menu Test.Test :')
|
||||
screen.update_menu = false
|
||||
|
||||
command('unmenu Test.Test')
|
||||
expect_sent(true)
|
||||
end)
|
||||
|
||||
it("should not be sent unnecessarily", function()
|
||||
feed('i12345<ESC>:redraw<CR>')
|
||||
expect_sent(false)
|
||||
end)
|
||||
|
||||
end)
|
||||
Reference in New Issue
Block a user