diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-08-19 23:43:19 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-08-27 21:19:10 +0200 |
commit | e1177be363f84f5f4f34c21b760bc47f70d5fa48 (patch) | |
tree | 054aa71f0cc72155ca9eb9c17625e8488ab56117 /src/nvim/api/vim.c | |
parent | 9e25a36467228bbcb8c6db88d2acb69cf7145af3 (diff) | |
download | rneovim-e1177be363f84f5f4f34c21b760bc47f70d5fa48.tar.gz rneovim-e1177be363f84f5f4f34c21b760bc47f70d5fa48.tar.bz2 rneovim-e1177be363f84f5f4f34c21b760bc47f70d5fa48.zip |
API: nvim_put #6819
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 31ddfa57f1..bafb21bd4e 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1206,21 +1206,18 @@ Dictionary nvim_get_namespaces(void) return retval; } -/// @param lines contents. One empty line for no-op, zero lines to emulate error +/// Inserts text at cursor. +/// +/// Compare |:put| and |p| which are always linewise. +/// +/// @param lines contents /// @param type type ("c", "l", "b") or empty to guess from contents -/// @param name if emulates put from a register, otherwise empty -/// @param prev True to emulate "P" otherwise "p" -/// @param count repeat count -/// @param[out] err details of an error that have occurred, if any. -void nvim_put(ArrayOf(String) lines, String type, String regname, Boolean prev, Integer count, Error *err) +/// @param direction behave like |P| instead of |p| +/// @param[out] err Error details, if any +void nvim_put(ArrayOf(String) lines, String type, Boolean direction, + Error *err) FUNC_API_SINCE(6) { - if (regname.size > 1) { - api_set_error(err, - kErrorTypeValidation, - "regname must be a single ASCII char or the empty string"); - return; - } yankreg_T *reg = xcalloc(sizeof(yankreg_T), 1); if (!prepare_yankreg_from_object(reg, type, lines.size)) { api_set_error(err, @@ -1229,6 +1226,9 @@ void nvim_put(ArrayOf(String) lines, String type, String regname, Boolean prev, type.data); return; } + if (lines.size == 0) { + goto cleanup; // Nothing to do. + } for (size_t i = 0; i < lines.size; i++) { if (lines.items[i].type != kObjectTypeString) { @@ -1244,7 +1244,6 @@ void nvim_put(ArrayOf(String) lines, String type, String regname, Boolean prev, finish_yankreg_from_object(reg, false); - int name = regname.size ? regname.data[0] : NUL; bool VIsual_was_active = VIsual_active; int flags = 0; if (State & INSERT) { @@ -1253,13 +1252,12 @@ void nvim_put(ArrayOf(String) lines, String type, String regname, Boolean prev, // TODO: fix VIsual when cursor is before, or emulate the delete as well flags |= lt(VIsual, curwin->w_cursor) ? PUT_CURSEND : 0; } - do_put(name, reg, prev ? BACKWARD : FORWARD, (long)count, flags); + do_put(0, reg, direction ? BACKWARD : FORWARD, 1, flags); VIsual_active = VIsual_was_active; cleanup: free_register(reg); xfree(reg); - } /// Subscribes to event broadcasts. |