Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf32fd19

Browse files
authored
fix(diagnostic): remove buf from cache onBufWipeout (#20099)
Doing so on `BufDelete` has issues: - `BufDelete` is also fired for listed buffers that are made unlisted. - `BufDelete` is not fired for unlisted buffers that are deleted.This means that diagnostics will be lost for a buffer that becomes unlisted.It also means that if an entry exists for an unlisted buffer, deleting thatbuffer later will not remove its entry from the cache (and you may see "Invalidbuffer id" errors when using diagnostic functions if it was wiped).Instead, remove a buffer from the cache if it is wiped out.This means simply `:bd`ing a buffer will not clear its diagnostics now.
1 parentb17c5c3 commitf32fd19

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

‎runtime/lua/vim/diagnostic.lua‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ local bufnr_and_namespace_cacher_mt = {
4747

4848
localdiagnostic_cache
4949
do
50-
localgroup=vim.api.nvim_create_augroup('DiagnosticBufDelete', {})
50+
localgroup=vim.api.nvim_create_augroup('DiagnosticBufWipeout', {})
5151
diagnostic_cache=setmetatable({}, {
5252
__index=function(t,bufnr)
5353
assert(bufnr>0,'Invalid buffer number')
54-
vim.api.nvim_create_autocmd('BufDelete', {
54+
vim.api.nvim_create_autocmd('BufWipeout', {
5555
group=group,
5656
buffer=bufnr,
5757
callback=function()

‎test/functional/lua/diagnostic_spec.lua‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ describe('vim.diagnostic', function()
148148
vim.cmd('bwipeout!')
149149
return #vim.diagnostic.get()
150150
]])
151+
eq(2,exec_lua[[
152+
vim.api.nvim_set_current_buf(diagnostic_bufnr)
153+
vim.opt_local.buflisted = false
154+
return #vim.diagnostic.get()
155+
]])
156+
eq(0,exec_lua[[
157+
vim.cmd('bwipeout!')
158+
return #vim.diagnostic.get()
159+
]])
151160
end)
152161

153162
it('resolves buffer number 0 to the current buffer',function()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp