diff options
author | notomo <notomo.motono@gmail.com> | 2021-08-26 23:37:36 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 16:37:36 +0200 |
commit | 274a3504a790a799b28ee89c75e29fb4dbdff41f (patch) | |
tree | caae17c39de08393d111a97a1c17f534032d17da /test/functional/lua/highlight_spec.lua | |
parent | 6ff1e3fa1f6c88e8a8ce4e2e5a017bea8b5e381e (diff) | |
download | rneovim-274a3504a790a799b28ee89c75e29fb4dbdff41f.tar.gz rneovim-274a3504a790a799b28ee89c75e29fb4dbdff41f.tar.bz2 rneovim-274a3504a790a799b28ee89c75e29fb4dbdff41f.zip |
fix(lua): verify buffer in highlight.on_yank (#15482)
Resolve an issue with deferred clearing of highlight failing if the
buffer is deleted before the timeout by checking whether the
buffer is valid first.
Diffstat (limited to 'test/functional/lua/highlight_spec.lua')
-rw-r--r-- | test/functional/lua/highlight_spec.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/functional/lua/highlight_spec.lua b/test/functional/lua/highlight_spec.lua new file mode 100644 index 0000000000..853b2991e8 --- /dev/null +++ b/test/functional/lua/highlight_spec.lua @@ -0,0 +1,26 @@ +local helpers = require('test.functional.helpers')(after_each) +local funcs = helpers.funcs +local exec_lua = helpers.exec_lua +local command = helpers.command +local clear = helpers.clear + +describe('vim.highlight.on_yank', function() + + before_each(function() + clear() + end) + + it('does not show errors even if buffer is wiped before timeout', function() + command('new') + local bufnr = funcs.bufnr("%") + exec_lua[[ + vim.highlight.on_yank({timeout = 10, on_macro = true, event = {operator = "y", regtype = "v"}}) + vim.cmd('bwipeout!') + ]] + exec_lua[[vim.wait(10)]] + local pattern = [[vim/highlight.lua:%d+: Invalid buffer id: ]] .. bufnr + local exists = pcall(helpers.assert_log, pattern) + assert.is_false(exists, string.format("%q should not be in log", pattern)) + end) + +end) |