mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
fix(diagnostic): escape special chars in file names (#16588)
This commit is contained in:
parent
5dcf2c77a9
commit
beac24d6f3
@ -655,7 +655,10 @@ function M.set(namespace, bufnr, diagnostics, opts)
|
|||||||
|
|
||||||
vim.api.nvim_buf_call(bufnr, function()
|
vim.api.nvim_buf_call(bufnr, function()
|
||||||
vim.api.nvim_command(
|
vim.api.nvim_command(
|
||||||
string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
|
string.format(
|
||||||
|
"doautocmd <nomodeline> DiagnosticChanged %s",
|
||||||
|
vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -1339,7 +1342,10 @@ function M.reset(namespace, bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_command(
|
vim.api.nvim_command(
|
||||||
string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
|
string.format(
|
||||||
|
"doautocmd <nomodeline> DiagnosticChanged %s",
|
||||||
|
vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1932,5 +1932,27 @@ describe('vim.diagnostic', function()
|
|||||||
return {show_called, hide_called}
|
return {show_called, hide_called}
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('triggers the autocommand when diagnostics are set', function()
|
||||||
|
eq(1, exec_lua [[
|
||||||
|
vim.g.diagnostic_autocmd_triggered = 0
|
||||||
|
vim.cmd('autocmd DiagnosticChanged * let g:diagnostic_autocmd_triggered = 1')
|
||||||
|
vim.api.nvim_buf_set_name(diagnostic_bufnr, "test | test")
|
||||||
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
|
||||||
|
make_error('Diagnostic', 0, 0, 0, 0)
|
||||||
|
})
|
||||||
|
return vim.g.diagnostic_autocmd_triggered
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('triggers the autocommand when diagnostics are cleared', function()
|
||||||
|
eq(1, exec_lua [[
|
||||||
|
vim.g.diagnostic_autocmd_triggered = 0
|
||||||
|
vim.cmd('autocmd DiagnosticChanged * let g:diagnostic_autocmd_triggered = 1')
|
||||||
|
vim.api.nvim_buf_set_name(diagnostic_bufnr, "test | test")
|
||||||
|
vim.diagnostic.reset(diagnostic_ns, diagnostic_bufnr)
|
||||||
|
return vim.g.diagnostic_autocmd_triggered
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user