diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2023-04-20 21:17:25 +0100 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2023-07-05 08:31:52 +0100 |
commit | 77118d0da8badc4135be430f4cbb15bc95bc760f (patch) | |
tree | e1168e881f49751b807524559720e5212661244e /src/nvim/api/vim.c | |
parent | b2e8c0df2062f765a4cf7d96379c5f0f19393dfd (diff) | |
download | rneovim-77118d0da8badc4135be430f4cbb15bc95bc760f.tar.gz rneovim-77118d0da8badc4135be430f4cbb15bc95bc760f.tar.bz2 rneovim-77118d0da8badc4135be430f4cbb15bc95bc760f.zip |
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.
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 8d34a34e8a..eacc833c58 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -612,7 +612,7 @@ String nvim_get_current_line(Error *err) /// @param[out] err Error details, if any void nvim_set_current_line(String line, Error *err) FUNC_API_SINCE(1) - FUNC_API_CHECK_TEXTLOCK + FUNC_API_TEXTLOCK_ALLOW_CMDWIN { buffer_set_line(curbuf->handle, curwin->w_cursor.lnum - 1, line, err); } @@ -622,7 +622,7 @@ void nvim_set_current_line(String line, Error *err) /// @param[out] err Error details, if any void nvim_del_current_line(Error *err) FUNC_API_SINCE(1) - FUNC_API_CHECK_TEXTLOCK + FUNC_API_TEXTLOCK_ALLOW_CMDWIN { buffer_del_line(curbuf->handle, curwin->w_cursor.lnum - 1, err); } @@ -803,7 +803,7 @@ Buffer nvim_get_current_buf(void) /// @param[out] err Error details, if any void nvim_set_current_buf(Buffer buffer, Error *err) FUNC_API_SINCE(1) - FUNC_API_CHECK_TEXTLOCK + FUNC_API_TEXTLOCK { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -858,7 +858,7 @@ Window nvim_get_current_win(void) /// @param[out] err Error details, if any void nvim_set_current_win(Window window, Error *err) FUNC_API_SINCE(1) - FUNC_API_CHECK_TEXTLOCK + FUNC_API_TEXTLOCK { win_T *win = find_window_by_handle(window, err); @@ -1084,7 +1084,7 @@ Tabpage nvim_get_current_tabpage(void) /// @param[out] err Error details, if any void nvim_set_current_tabpage(Tabpage tabpage, Error *err) FUNC_API_SINCE(1) - FUNC_API_CHECK_TEXTLOCK + FUNC_API_TEXTLOCK { tabpage_T *tp = find_tab_by_handle(tabpage, err); @@ -1126,7 +1126,7 @@ void nvim_set_current_tabpage(Tabpage tabpage, Error *err) /// - false: Client must cancel the paste. Boolean nvim_paste(String data, Boolean crlf, Integer phase, Error *err) FUNC_API_SINCE(6) - FUNC_API_CHECK_TEXTLOCK + FUNC_API_TEXTLOCK_ALLOW_CMDWIN { static bool draining = false; bool cancel = false; @@ -1197,7 +1197,7 @@ theend: /// @param[out] err Error details, if any void nvim_put(ArrayOf(String) lines, String type, Boolean after, Boolean follow, Error *err) FUNC_API_SINCE(6) - FUNC_API_CHECK_TEXTLOCK + FUNC_API_TEXTLOCK_ALLOW_CMDWIN { yankreg_T *reg = xcalloc(1, sizeof(yankreg_T)); VALIDATE_S((prepare_yankreg_from_object(reg, type, lines.size)), "type", type.data, { |