aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/lua')
-rw-r--r--src/nvim/lua/executor.c4
-rw-r--r--src/nvim/lua/stdlib.c6
-rw-r--r--src/nvim/lua/treesitter.c2
3 files changed, 6 insertions, 6 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 1a9bd026b5..08677b77b0 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -1767,7 +1767,7 @@ void ex_luado(exarg_T *const eap)
lua_pushvalue(lstate, -1);
const char *const old_line = ml_get_buf(curbuf, l);
// Get length of old_line here as calling Lua code may free it.
- const size_t old_line_len = strlen(old_line);
+ const colnr_T old_line_len = ml_get_buf_len(curbuf, l);
lua_pushstring(lstate, old_line);
lua_pushnumber(lstate, (lua_Number)l);
if (nlua_pcall(lstate, 2, 1)) {
@@ -1791,7 +1791,7 @@ void ex_luado(exarg_T *const eap)
}
}
ml_replace(l, new_line_transformed, false);
- inserted_bytes(l, 0, (int)old_line_len, (int)new_line_len);
+ inserted_bytes(l, 0, old_line_len, (int)new_line_len);
}
lua_pop(lstate, 1);
}
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index 8f58fd1a1a..a5262efcfa 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -107,15 +107,15 @@ static int regex_match_line(lua_State *lstate)
}
char *line = ml_get_buf(buf, rownr + 1);
- size_t len = strlen(line);
+ colnr_T len = ml_get_buf_len(buf, rownr + 1);
- if (start < 0 || (size_t)start > len) {
+ if (start < 0 || start > len) {
return luaL_error(lstate, "invalid start");
}
char save = NUL;
if (end >= 0) {
- if ((size_t)end > len || end < start) {
+ if (end > len || end < start) {
return luaL_error(lstate, "invalid end");
}
save = line[end];
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index 25a753b179..6d6ef6c7b9 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -371,7 +371,7 @@ static const char *input_cb(void *payload, uint32_t byte_index, TSPoint position
return "";
}
char *line = ml_get_buf(bp, (linenr_T)position.row + 1);
- size_t len = strlen(line);
+ size_t len = (size_t)ml_get_buf_len(bp, (linenr_T)position.row + 1);
if (position.column > len) {
*bytes_read = 0;
return "";