+27
-2
lines changedFilter options
+27
-2
lines changed Original file line number Diff line number Diff line change
@@ -658,7 +658,10 @@ function M.set(namespace, bufnr, diagnostics, opts)
658
658
659
659
vim.api.nvim_buf_call(bufnr, function()
660
660
vim.api.nvim_command(
661
-
string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
661
+
string.format(
662
+
"doautocmd <nomodeline> DiagnosticChanged %s",
663
+
vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr))
664
+
)
662
665
)
663
666
end)
664
667
end
@@ -1333,7 +1336,7 @@ function M.reset(namespace, bufnr)
1333
1336
end
1334
1337
1335
1338
vim.api.nvim_command(
1336
-
string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
1339
+
string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr)))
1337
1340
)
1338
1341
end
1339
1342
Original file line number Diff line number Diff line change
@@ -1918,5 +1918,27 @@ describe('vim.diagnostic', function()
1918
1918
return {show_called, hide_called}
1919
1919
]])
1920
1920
end)
1921
+
1922
+
it('triggers the autocommand when diagnostics are set', function()
1923
+
eq(1, exec_lua [[
1924
+
vim.g.diagnostic_autocmd_triggered = 0
1925
+
vim.cmd('autocmd DiagnosticChanged * let g:diagnostic_autocmd_triggered = 1')
1926
+
vim.api.nvim_buf_set_name(diagnostic_bufnr, "test | test")
1927
+
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
1928
+
make_error('Diagnostic', 0, 0, 0, 0)
1929
+
})
1930
+
return vim.g.diagnostic_autocmd_triggered
1931
+
]])
1932
+
end)
1933
+
1934
+
it('triggers the autocommand when diagnostics are cleared', function()
1935
+
eq(1, exec_lua [[
1936
+
vim.g.diagnostic_autocmd_triggered = 0
1937
+
vim.cmd('autocmd DiagnosticChanged * let g:diagnostic_autocmd_triggered = 1')
1938
+
vim.api.nvim_buf_set_name(diagnostic_bufnr, "test | test")
1939
+
vim.diagnostic.reset(diagnostic_ns, diagnostic_bufnr)
1940
+
return vim.g.diagnostic_autocmd_triggered
1941
+
]])
1942
+
end)
1921
1943
end)
1922
1944
end)
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4