aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/api.txt13
-rw-r--r--src/nvim/api/extmark.c11
-rw-r--r--src/nvim/api/private/helpers.c2
-rw-r--r--src/nvim/ex_docmd.c5
4 files changed, 17 insertions, 14 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 7c669e3c9d..58ec9756a2 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -2656,13 +2656,12 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
Creates or updates an extmark.
- To create a new extmark, pass id=0. The extmark id will be
- returned. To move an existing mark, pass its id.
-
- It is also allowed to create a new mark by passing in a
- previously unused id, but the caller must then keep track of
- existing and unused ids itself. (Useful over RPC, to avoid
- waiting for the return value.)
+ By default a new extmark is created when no id is passed in,
+ but it is also possible to create a new mark by passing in a
+ previously unused id or move an existing mark by passing in
+ its id. The caller must then keep track of existing and unused
+ ids itself. (Useful over RPC, to avoid waiting for the return
+ value.)
Using the optional arguments, it is possible to use this to
highlight a range of text, and also to associate virtual text
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index d80bec2f70..94b2af9a6f 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -366,12 +366,11 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e
/// Creates or updates an extmark.
///
-/// To create a new extmark, pass id=0. The extmark id will be returned.
-/// To move an existing mark, pass its id.
-///
-/// It is also allowed to create a new mark by passing in a previously unused
-/// id, but the caller must then keep track of existing and unused ids itself.
-/// (Useful over RPC, to avoid waiting for the return value.)
+/// By default a new extmark is created when no id is passed in, but it is also
+/// possible to create a new mark by passing in a previously unused id or move
+/// an existing mark by passing in its id. The caller must then keep track of
+/// existing and unused ids itself. (Useful over RPC, to avoid waiting for the
+/// return value.)
///
/// Using the optional arguments, it is possible to use this to highlight
/// a range of text, and also to associate virtual text to the mark.
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 5d4b84482b..adabb1471e 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -1616,7 +1616,7 @@ void create_user_command(String name, Object command, Dict(user_command) *opts,
if (uc_add_command(name.data, name.size, rep, argt, def, flags, compl, compl_arg, compl_luaref,
addr_type_arg, luaref, force) != OK) {
api_set_error(err, kErrorTypeException, "Failed to create user command");
- goto err;
+ // Do not goto err, since uc_add_command now owns luaref, compl_luaref, and compl_arg
}
return;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 5f9d73a25a..6d1e1c073b 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -5528,6 +5528,11 @@ char *uc_validate_name(char *name)
return name;
}
+/// Create a new user command {name}, if one doesn't already exist.
+///
+/// This function takes ownership of compl_arg, compl_luaref, and luaref.
+///
+/// @return OK if the command is created, FAIL otherwise.
int uc_add_command(char *name, size_t name_len, char *rep, uint32_t argt, long def, int flags,
int compl, char *compl_arg, LuaRef compl_luaref, cmd_addr_T addr_type,
LuaRef luaref, bool force)