aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/diagnostic_spec.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2021-11-04 06:59:24 -0600
committerGitHub <noreply@github.com>2021-11-04 06:59:24 -0600
commitfd347840ba95b2709b90d5a3131f59b72fbad7fb (patch)
treec475b8c2e9fbbbe94c32d3c01cb587a838074ba5 /test/functional/lua/diagnostic_spec.lua
parentf26b391317281d0520056eaa8312cf25e654149f (diff)
downloadrneovim-fd347840ba95b2709b90d5a3131f59b72fbad7fb.tar.gz
rneovim-fd347840ba95b2709b90d5a3131f59b72fbad7fb.tar.bz2
rneovim-fd347840ba95b2709b90d5a3131f59b72fbad7fb.zip
fix(diagnostic): fix option resolution in open_float (#16229)
Diffstat (limited to 'test/functional/lua/diagnostic_spec.lua')
-rw-r--r--test/functional/lua/diagnostic_spec.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index 00011687a9..e8bbee671e 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -1240,6 +1240,41 @@ describe('vim.diagnostic', function()
return lines
]])
end)
+
+ it('can filter by severity', function()
+ local count_diagnostics_with_severity = function(min_severity, max_severity)
+ return exec_lua([[
+ local min_severity, max_severity = ...
+ vim.diagnostic.config({
+ float = {
+ severity = {min=min_severity, max=max_severity},
+ },
+ })
+
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
+ make_error("Syntax error", 0, 1, 0, 3),
+ make_info('Info', 0, 3, 0, 4),
+ make_error('Error', 0, 2, 0, 2),
+ make_warning('Warning', 0, 0, 0, 1),
+ })
+
+ local float_bufnr, winnr = vim.diagnostic.open_float(diagnostic_bufnr, { show_header = false })
+ if not float_bufnr then
+ return 0
+ end
+
+ local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
+ vim.api.nvim_win_close(winnr, true)
+ return #lines
+ ]], min_severity, max_severity)
+ end
+
+ eq(2, count_diagnostics_with_severity("ERROR"))
+ eq(3, count_diagnostics_with_severity("WARN"))
+ eq(1, count_diagnostics_with_severity("WARN", "WARN"))
+ eq(4, count_diagnostics_with_severity("HINT"))
+ eq(0, count_diagnostics_with_severity("HINT", "HINT"))
+ end)
end)
describe('setloclist()', function()