fix(ctx): missing options copy when loading hidden buffer #41149

It's necessary to copy the global 'fileencoding' to the buffer-local
value before entering the buffer, otherwise 'fileencoding' is changed
when reading the file, which will mark the file as modified.
This commit is contained in:
zeertzjq
2026-08-04 16:50:36 +08:00
committed by GitHub
parent 434792787b
commit 30b4c1b40d
2 changed files with 18 additions and 0 deletions

View File

@@ -324,3 +324,19 @@ describe('setbufvar() function', function()
eq('Vim:E928: String required', pcall_err(fn.setbufvar, '', '&errorformat', true))
end)
end)
describe('bufload() function', function()
before_each(function()
t.write_file(fname, 'foo\n')
end)
after_each(function()
os.remove(fname)
end)
it('does not set hidden buffer as modified #41148', function()
local buf = fn.bufadd(fname)
fn.bufload(buf)
api.nvim_command('edit ' .. fname)
eq(true, api.nvim_buf_is_loaded(buf))
eq(false, api.nvim_get_option_value('modified', { buf = buf }))
end)
end)