diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-09-17 11:31:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-17 11:31:56 -0700 |
commit | ede5695eb194e9b607421415525177888b447753 (patch) | |
tree | 0d14ccef65029e69c839b9606e4b39a98e4b3971 /test | |
parent | 4d7dcbe49f4a1cd691211e4fd316af51241f6544 (diff) | |
parent | 32c0631183a64925d38a13819db9557f8da02738 (diff) | |
download | rneovim-ede5695eb194e9b607421415525177888b447753.tar.gz rneovim-ede5695eb194e9b607421415525177888b447753.tar.bz2 rneovim-ede5695eb194e9b607421415525177888b447753.zip |
Merge pull request #15696 from gpanders/diagnostic-sign-fix
Diagnostic hot fixes
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/lua/diagnostic_spec.lua | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua index 8da33173a2..3c8d6e8f2c 100644 --- a/test/functional/lua/diagnostic_spec.lua +++ b/test/functional/lua/diagnostic_spec.lua @@ -35,7 +35,7 @@ describe('vim.diagnostic', function() } end - function make_information(msg, x1, y1, x2, y2) + function make_info(msg, x1, y1, x2, y2) return { lnum = x1, col = y1, @@ -456,7 +456,7 @@ describe('vim.diagnostic', function() vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, { make_error("Error 1", 1, 1, 1, 5), make_warning("Warning on Server 1", 1, 1, 2, 5), - make_information("Ignored information", 1, 1, 2, 5), + make_info("Ignored information", 1, 1, 2, 5), make_hint("Here's a hint", 1, 1, 2, 5), }) @@ -478,7 +478,7 @@ describe('vim.diagnostic', function() vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, { make_error("Error 1", 1, 1, 1, 5), make_warning("Warning on Server 1", 1, 1, 2, 5), - make_information("Ignored information", 1, 1, 2, 5), + make_info("Ignored information", 1, 1, 2, 5), make_error("Error On Other Line", 2, 1, 1, 5), }) @@ -538,6 +538,47 @@ describe('vim.diagnostic', function() eq(1, get_extmark_count_with_severity("WARN")) eq(1, get_extmark_count_with_severity("HINT")) end) + + it('allows sorting by severity', function() + local result = exec_lua([[ + vim.diagnostic.config({ + underline = true, + virtual_text = false, + severity_sort = false, + }) + + vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, { + make_warning('Warning', 4, 4, 4, 4), + make_error('Error', 4, 4, 4, 4), + make_info('Info', 4, 4, 4, 4), + }) + + local extmarks = vim.api.nvim_buf_get_extmarks(diagnostic_bufnr, diagnostic_ns, 0, -1, {details = true}) + + local warn_highlight = extmarks[1][4].hl_group + + vim.diagnostic.config({ + severity_sort = true, + }) + + extmarks = vim.api.nvim_buf_get_extmarks(diagnostic_bufnr, diagnostic_ns, 0, -1, {details = true}) + + local err_highlight = extmarks[1][4].hl_group + + vim.diagnostic.config({ + severity_sort = { reverse = true }, + }) + + extmarks = vim.api.nvim_buf_get_extmarks(diagnostic_bufnr, diagnostic_ns, 0, -1, {details = true}) + + local info_highlight = extmarks[1][4].hl_group + + return { warn_highlight, err_highlight, info_highlight } + ]]) + eq('DiagnosticUnderlineWarn', result[1]) + eq('DiagnosticUnderlineError', result[2]) + eq('DiagnosticUnderlineInfo', result[3]) + end) end) describe('set()', function() |