aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-04-13 15:00:42 +0200
committerGitHub <noreply@github.com>2021-04-13 15:00:42 +0200
commitc9817603cff5a5ca7ef4e4c12c8bf0e16d859e9a (patch)
tree2fa45a0d2001461cffed58cccd1a297724875178 /src/nvim/lua/executor.c
parentef3f05c43267142aaf92f451d5da21f7c2ac638f (diff)
parentff43d9597e26d202051f977fe57058797b9f1c99 (diff)
downloadrneovim-c9817603cff5a5ca7ef4e4c12c8bf0e16d859e9a.tar.gz
rneovim-c9817603cff5a5ca7ef4e4c12c8bf0e16d859e9a.tar.bz2
rneovim-c9817603cff5a5ca7ef4e4c12c8bf0e16d859e9a.zip
Merge pull request #14318 from chentau/extmark_luado
extmark: splice extmarks on :luado
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r--src/nvim/lua/executor.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 9b8e9ff8cc..f99a2dd0fe 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -17,6 +17,7 @@
#include "nvim/api/vim.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/vim.h"
+#include "nvim/extmark.h"
#include "nvim/ex_getln.h"
#include "nvim/ex_cmds2.h"
#include "nvim/map.h"
@@ -1243,13 +1244,16 @@ void ex_luado(exarg_T *const eap)
break;
}
lua_pushvalue(lstate, -1);
- lua_pushstring(lstate, (const char *)ml_get_buf(curbuf, l, false));
+ const char *old_line = (const char *)ml_get_buf(curbuf, l, false);
+ lua_pushstring(lstate, old_line);
lua_pushnumber(lstate, (lua_Number)l);
if (lua_pcall(lstate, 2, 1, 0)) {
nlua_error(lstate, _("E5111: Error calling lua: %.*s"));
break;
}
if (lua_isstring(lstate, -1)) {
+ size_t old_line_len = STRLEN(old_line);
+
size_t new_line_len;
const char *const new_line = lua_tolstring(lstate, -1, &new_line_len);
char *const new_line_transformed = xmemdupz(new_line, new_line_len);
@@ -1259,7 +1263,7 @@ void ex_luado(exarg_T *const eap)
}
}
ml_replace(l, (char_u *)new_line_transformed, false);
- changed_bytes(l, 0);
+ inserted_bytes(l, 0, (int)old_line_len, (int)new_line_len);
}
lua_pop(lstate, 1);
}