mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 22:08:18 +00:00
fix(api): use text_locked() to check textlock
Problem: some API functions that check textlock (usually those that can change curwin or curbuf) can break the cmdwin. Solution: make FUNC_API_CHECK_TEXTLOCK call text_locked() instead, which already checks for textlock, cmdwin and `<expr>` status. Add FUNC_API_TEXTLOCK_ALLOW_CMDWIN to allow such functions to be usable in the cmdwin if they can work properly there; the opt-in nature of this attribute should hopefully help mitigate future bugs. Also fix a regression in #22634 that made functions checking textlock usable in `<expr>` mappings, and rename FUNC_API_CHECK_TEXTLOCK to FUNC_API_TEXTLOCK.
This commit is contained in:
@@ -347,7 +347,7 @@ end:
|
||||
void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integer end,
|
||||
Boolean strict_indexing, ArrayOf(String) replacement, Error *err)
|
||||
FUNC_API_SINCE(1)
|
||||
FUNC_API_CHECK_TEXTLOCK
|
||||
FUNC_API_TEXTLOCK_ALLOW_CMDWIN
|
||||
{
|
||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||
|
||||
@@ -1061,7 +1061,7 @@ Boolean nvim_buf_is_loaded(Buffer buffer)
|
||||
/// - unload: Unloaded only, do not delete. See |:bunload|
|
||||
void nvim_buf_delete(Buffer buffer, Dictionary opts, Error *err)
|
||||
FUNC_API_SINCE(7)
|
||||
FUNC_API_CHECK_TEXTLOCK
|
||||
FUNC_API_TEXTLOCK
|
||||
{
|
||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||
|
||||
|
Reference in New Issue
Block a user