fix(health): always set 'modifiable' #40584

Problem:
When buffers are by default `nomodifiable`, such as when Nvim starts with
`-M`, the health buffer cannot be updated.

Solution:
Always set `modifiable` before modifying the buffer.
This commit is contained in:
dqnne
2026-07-05 12:09:27 +02:00
committed by GitHub
parent 656b4d9c34
commit 0f86ea5ed8
2 changed files with 7 additions and 1 deletions

View File

@@ -414,7 +414,6 @@ function M._check(eap)
close_events = {},
})
vim.api.nvim_set_current_win(float_winid)
vim.bo[bufnr].modifiable = true
vim.wo[float_winid].list = false
else
bufnr = vim.api.nvim_create_buf(true, true)
@@ -430,6 +429,7 @@ function M._check(eap)
vim.cmd.sbuffer { bufnr, mods = { tab = vim.api.nvim_tabpage_get_number(0) } }
end
end
vim.bo[bufnr].modifiable = true
if vim.fn.bufexists('health://') == 1 then
vim.cmd.bwipe('health://')

View File

@@ -140,6 +140,12 @@ describe(':checkhealth', function()
eq(true, report:find('- custom_ft:', 1, true) ~= nil)
eq(true, report:find('- bad_ft:', 1, true) ~= nil)
end)
it('renders report when Nvim starts with -M', function()
clear { args = { '-M' } }
command('checkhealth lsp')
eq(true, curbuf_contents() ~= '')
end)
end)
describe('vim.health', function()