diff options
author | Gregory Anders <greg@gpanders.com> | 2021-09-18 10:05:34 -0600 |
---|---|---|
committer | Gregory Anders <greg@gpanders.com> | 2021-09-18 10:07:54 -0600 |
commit | 752d2d2081a72bcb7698d75b5344c2cae06132cb (patch) | |
tree | b29a4324cea9d774bafe5fd6ca0f491ec627e2ed /test/functional/lua/diagnostic_spec.lua | |
parent | ef52433847d990623be15d70ad008fe92aa544ef (diff) | |
download | rneovim-752d2d2081a72bcb7698d75b5344c2cae06132cb.tar.gz rneovim-752d2d2081a72bcb7698d75b5344c2cae06132cb.tar.bz2 rneovim-752d2d2081a72bcb7698d75b5344c2cae06132cb.zip |
test: add test case for show_line_diagnostics
Diffstat (limited to 'test/functional/lua/diagnostic_spec.lua')
-rw-r--r-- | test/functional/lua/diagnostic_spec.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua index 2971d3bc51..589e0f3e6b 100644 --- a/test/functional/lua/diagnostic_spec.lua +++ b/test/functional/lua/diagnostic_spec.lua @@ -795,6 +795,39 @@ describe('vim.diagnostic', function() ]]) end) + it('only reports diagnostics from the current buffer when bufnr is omitted #15710', function() + eq(2, exec_lua [[ + local other_bufnr = vim.api.nvim_create_buf(true, false) + local buf_1_diagnostics = { + make_error("Syntax error", 0, 1, 0, 3), + } + local buf_2_diagnostics = { + make_warning("Some warning", 0, 1, 0, 3), + } + vim.api.nvim_win_set_buf(0, diagnostic_bufnr) + vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, buf_1_diagnostics) + vim.diagnostic.set(other_ns, other_bufnr, buf_2_diagnostics) + local popup_bufnr, winnr = vim.diagnostic.show_line_diagnostics() + return #vim.api.nvim_buf_get_lines(popup_bufnr, 0, -1, false) + ]]) + end) + + it('allows filtering by namespace', function() + eq(2, exec_lua [[ + local ns_1_diagnostics = { + make_error("Syntax error", 0, 1, 0, 3), + } + local ns_2_diagnostics = { + make_warning("Some warning", 0, 1, 0, 3), + } + vim.api.nvim_win_set_buf(0, diagnostic_bufnr) + vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, ns_1_diagnostics) + vim.diagnostic.set(other_ns, diagnostic_bufnr, ns_2_diagnostics) + local popup_bufnr, winnr = vim.diagnostic.show_line_diagnostics({namespace = diagnostic_ns}) + return #vim.api.nvim_buf_get_lines(popup_bufnr, 0, -1, false) + ]]) + end) + it('creates floating window and returns popup bufnr and winnr without header, if requested', function() -- One line (since no header): -- 1. <msg> |