diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2021-11-09 14:33:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 14:33:01 -0700 |
commit | 953ae71fd324eb1a263d2b7435cc15756b44ac2d (patch) | |
tree | 5ad0af3b8dd0036a21bb1f502e6918ed5974a486 /test/functional/lua/diagnostic_spec.lua | |
parent | 8f31b218f97d143d909d4b8b86dc528e70c151e3 (diff) | |
download | rneovim-953ae71fd324eb1a263d2b7435cc15756b44ac2d.tar.gz rneovim-953ae71fd324eb1a263d2b7435cc15756b44ac2d.tar.bz2 rneovim-953ae71fd324eb1a263d2b7435cc15756b44ac2d.zip |
feat(diagnostic): do not require namespace for hide() and show() (#16261)
Also fix a few other small bugs regarding saving and restoring extmarks.
In particular, now that the virtual text and underline handlers have
their own dedicated namespaces, they should be responsible for saving
and restoring their own extmarks. Also fix the wrong argument ordering
in the call to `clear_diagnostic_cache` in the `on_detach` callback.
Diffstat (limited to 'test/functional/lua/diagnostic_spec.lua')
-rw-r--r-- | test/functional/lua/diagnostic_spec.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua index e8bbee671e..bb2d39c8b2 100644 --- a/test/functional/lua/diagnostic_spec.lua +++ b/test/functional/lua/diagnostic_spec.lua @@ -268,6 +268,56 @@ describe('vim.diagnostic', function() ]]) end) + describe('show() and hide()', function() + it('works', function() + local result = exec_lua [[ + vim.api.nvim_win_set_buf(0, diagnostic_bufnr) + + local result = {} + + vim.diagnostic.config({ underline = false, virtual_text = true }) + + local ns_1_diags = { + make_error("Error 1", 1, 1, 1, 5), + make_warning("Warning on Server 1", 2, 1, 2, 5), + } + local ns_2_diags = { + make_warning("Warning 1", 2, 1, 2, 5), + } + + vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, ns_1_diags) + vim.diagnostic.set(other_ns, diagnostic_bufnr, ns_2_diags) + + -- Both + table.insert(result, count_extmarks(diagnostic_bufnr, diagnostic_ns) + count_extmarks(diagnostic_bufnr, other_ns)) + + -- Hide one namespace + vim.diagnostic.hide(diagnostic_ns) + table.insert(result, count_extmarks(diagnostic_bufnr, diagnostic_ns)) + + -- Show one namespace + vim.diagnostic.show(diagnostic_ns) + table.insert(result, count_extmarks(diagnostic_bufnr, diagnostic_ns)) + + -- Hide all namespaces + vim.diagnostic.hide() + table.insert(result, count_extmarks(diagnostic_bufnr, diagnostic_ns) + count_extmarks(diagnostic_bufnr, other_ns)) + + -- Show all namespaces + vim.diagnostic.show() + table.insert(result, count_extmarks(diagnostic_bufnr, diagnostic_ns) + count_extmarks(diagnostic_bufnr, other_ns)) + + return result + ]] + + eq(3, result[1]) + eq(0, result[2]) + eq(2, result[3]) + eq(0, result[4]) + eq(3, result[5]) + end) + end) + describe('reset()', function() it('diagnostic count is 0 and displayed diagnostics are 0 after call', function() -- 1 Error (1) |