mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 09:48:19 +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:
@@ -48,7 +48,7 @@ Buffer nvim_win_get_buf(Window window, Error *err)
|
||||
/// @param[out] err Error details, if any
|
||||
void nvim_win_set_buf(Window window, Buffer buffer, Error *err)
|
||||
FUNC_API_SINCE(5)
|
||||
FUNC_API_CHECK_TEXTLOCK
|
||||
FUNC_API_TEXTLOCK
|
||||
{
|
||||
win_set_buf(window, buffer, false, err);
|
||||
}
|
||||
@@ -351,7 +351,7 @@ Boolean nvim_win_is_valid(Window window)
|
||||
/// @param[out] err Error details, if any
|
||||
void nvim_win_hide(Window window, Error *err)
|
||||
FUNC_API_SINCE(7)
|
||||
FUNC_API_CHECK_TEXTLOCK
|
||||
FUNC_API_TEXTLOCK
|
||||
{
|
||||
win_T *win = find_window_by_handle(window, err);
|
||||
if (!win) {
|
||||
@@ -383,7 +383,7 @@ void nvim_win_hide(Window window, Error *err)
|
||||
/// @param[out] err Error details, if any
|
||||
void nvim_win_close(Window window, Boolean force, Error *err)
|
||||
FUNC_API_SINCE(6)
|
||||
FUNC_API_CHECK_TEXTLOCK
|
||||
FUNC_API_TEXTLOCK_ALLOW_CMDWIN
|
||||
{
|
||||
win_T *win = find_window_by_handle(window, err);
|
||||
if (!win) {
|
||||
|
Reference in New Issue
Block a user