mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
fix(api): disallow some more functions during textlock
Problem: nvim_buf_set_text(), nvim_open_term() and termopen() all change buffer text, which is forbidden during textlock. Additionally, nvim_open_term() and termopen() may be used to convert the cmdwin buffer into a terminal buffer, which is weird. Solution: Allow nvim_buf_set_text() and nvim_open_term() in the cmdwin, but disallow nvim_open_term() from converting the cmdwin buffer into a terminal buffer. termopen() is not allowed in the cmdwin (as it always operates on curbuf), so just check text_locked(). Also happens to improve the error in #21055: nvim_buf_set_text() was callable during textlock, but happened to check textlock indirectly via u_save(); however, this caused the error to be overwritten by an unhelpful "Failed to save undo information" message when msg_list == NULL (e.g: an `<expr>` mapping invoked outside of do_cmdline()).
This commit is contained in:
@@ -498,3 +498,17 @@ if is_os('win') then
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
describe('termopen()', function()
|
||||
before_each(clear)
|
||||
|
||||
it('disallowed when textlocked and in cmdwin buffer', function()
|
||||
command("autocmd TextYankPost <buffer> ++once call termopen('foo')")
|
||||
matches("Vim%(call%):E565: Not allowed to change text or change window$",
|
||||
pcall_err(command, "normal! yy"))
|
||||
|
||||
feed("q:")
|
||||
eq("Vim:E11: Invalid in command-line window; <CR> executes, CTRL-C quits",
|
||||
pcall_err(funcs.termopen, "bar"))
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user