aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/lua')
-rw-r--r--src/nvim/lua/converter.c16
-rw-r--r--src/nvim/lua/stdlib.c6
-rw-r--r--src/nvim/lua/vim.lua3
3 files changed, 13 insertions, 12 deletions
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c
index 9f2372f831..b6792a5a97 100644
--- a/src/nvim/lua/converter.c
+++ b/src/nvim/lua/converter.c
@@ -782,10 +782,10 @@ void nlua_push_Object(lua_State *lstate, const Object obj, bool special)
break;
}
#define ADD_TYPE(type, data_key) \
-case kObjectType##type: { \
- nlua_push_##type(lstate, obj.data.data_key, special); \
- break; \
-}
+ case kObjectType##type: { \
+ nlua_push_##type(lstate, obj.data.data_key, special); \
+ break; \
+ }
ADD_TYPE(Boolean, boolean)
ADD_TYPE(Integer, integer)
ADD_TYPE(Float, floating)
@@ -794,10 +794,10 @@ case kObjectType##type: { \
ADD_TYPE(Dictionary, dictionary)
#undef ADD_TYPE
#define ADD_REMOTE_TYPE(type) \
-case kObjectType##type: { \
- nlua_push_##type(lstate, (type)obj.data.integer, special); \
- break; \
-}
+ case kObjectType##type: { \
+ nlua_push_##type(lstate, (type)obj.data.integer, special); \
+ break; \
+ }
ADD_REMOTE_TYPE(Buffer)
ADD_REMOTE_TYPE(Window)
ADD_REMOTE_TYPE(Tabpage)
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index db79e9e7e9..b5553060a1 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -175,13 +175,13 @@ int nlua_str_utfindex(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
size_t s1_len;
const char *s1 = luaL_checklstring(lstate, 1, &s1_len);
intptr_t idx;
- if (lua_gettop(lstate) >= 2) {
+ if (lua_isnoneornil(lstate, 2)) {
+ idx = (intptr_t)s1_len;
+ } else {
idx = luaL_checkinteger(lstate, 2);
if (idx < 0 || idx > (intptr_t)s1_len) {
return luaL_error(lstate, "index out of range");
}
- } else {
- idx = (intptr_t)s1_len;
}
size_t codepoints = 0, codeunits = 0;
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index ad886b40dd..c1a1e7f162 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -454,7 +454,7 @@ local on_key_cbs = {}
--- On each key press, Nvim passes the key char to fn(). |i_CTRL-V|
--- If {fn} is nil, it removes the callback for the associated {ns_id}
---@param ns_id number? Namespace ID. If nil or 0, generates and returns a new
---- |nvim_create_namesapce()| id.
+--- |nvim_create_namespace()| id.
---
---@return number Namespace id associated with {fn}. Or count of all callbacks
---if on_key() is called without arguments.
@@ -580,6 +580,7 @@ function vim._expand_pat(pat, env)
end
local keys = {}
+ ---@private
local function insert_keys(obj)
for k,_ in pairs(obj) do
if type(k) == "string" and string.sub(k,1,string.len(match_part)) == match_part then