mirror of
https://github.com/neovim/neovim.git
synced 2026-04-19 22:10:45 +00:00
refactor(change): do API changes to buffer without curbuf switch
Most of the messy things when changing a non-current buffer is not about the buffer, it is about windows. In particular, it is about `curwin`. When editing a non-current buffer which is displayed in some other window in the current tabpage, one such window will be "borrowed" as the curwin. But this means if two or more non-current windows displayed the buffers, one of them will be treated differenty. this is not desirable. In particular, with nvim_buf_set_text, cursor _column_ position was only corrected for one single window. Two new tests are added: the test with just one non-current window passes, but the one with two didn't. Two corresponding such tests were also added for nvim_buf_set_lines. This already worked correctly on master, but make sure this is well-tested for future refactors. Also, nvim_create_buf no longer invokes autocmds just because you happened to use `scratch=true`. No option value was changed, therefore OptionSet must not be fired.
This commit is contained in:
@@ -28,7 +28,6 @@ local write_file = helpers.write_file
|
||||
local exec_lua = helpers.exec_lua
|
||||
local exc_exec = helpers.exc_exec
|
||||
local insert = helpers.insert
|
||||
local expect_exit = helpers.expect_exit
|
||||
local skip = helpers.skip
|
||||
|
||||
local pcall_err = helpers.pcall_err
|
||||
@@ -2832,7 +2831,9 @@ describe('API', function()
|
||||
|
||||
it('does not cause heap-use-after-free on exit while setting options', function()
|
||||
command('au OptionSet * q')
|
||||
expect_exit(command, 'silent! call nvim_create_buf(0, 1)')
|
||||
command('silent! call nvim_create_buf(0, 1)')
|
||||
-- nowadays this works because we don't execute any spurious autocmds at all #24824
|
||||
assert_alive()
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user