diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-07-05 17:04:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-05 17:04:17 +0800 |
commit | 8a788e2daa5c62201f2bb278522eddd42f315d41 (patch) | |
tree | e92a4873cffa28ae5f62683191c93ac08538815f /src/nvim/api/vim.c | |
parent | df297e3c2bd743616371db73467a3f08d2b96d9b (diff) | |
parent | aa4e47f704c53ab1d825260d2bf34e2872e3ca89 (diff) | |
download | rneovim-8a788e2daa5c62201f2bb278522eddd42f315d41.tar.gz rneovim-8a788e2daa5c62201f2bb278522eddd42f315d41.tar.bz2 rneovim-8a788e2daa5c62201f2bb278522eddd42f315d41.zip |
Merge pull request #23228 from seandewar/cmdwin-jail
fix(api): use `text_locked()` to check for textlock
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 8d34a34e8a..8c40e5ccd7 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); @@ -951,12 +951,18 @@ fail: /// @return Channel id, or 0 on error Integer nvim_open_term(Buffer buffer, DictionaryOf(LuaRef) opts, Error *err) FUNC_API_SINCE(7) + FUNC_API_TEXTLOCK_ALLOW_CMDWIN { buf_T *buf = find_buffer_by_handle(buffer, err); if (!buf) { return 0; } + if (cmdwin_type != 0 && buf == curbuf) { + api_set_error(err, kErrorTypeException, "%s", _(e_cmdwin)); + return 0; + } + LuaRef cb = LUA_NOREF; for (size_t i = 0; i < opts.size; i++) { String k = opts.items[i].key; @@ -1084,7 +1090,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 +1132,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 +1203,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, { |