aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/treesitter.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2020-09-10 08:50:42 +0200
committerGitHub <noreply@github.com>2020-09-10 08:50:42 +0200
commit5581ac88c60b0a3f7595088b30a8621f280b5e4c (patch)
tree134b85598a37003b2339bc996f934759b826918f /src/nvim/lua/treesitter.c
parent0f41caa265602f8a6bc9f30f28d9f726699075cb (diff)
parentef5e7b862db38d3b0376417e137c6463c4d909e6 (diff)
downloadrneovim-5581ac88c60b0a3f7595088b30a8621f280b5e4c.tar.gz
rneovim-5581ac88c60b0a3f7595088b30a8621f280b5e4c.tar.bz2
rneovim-5581ac88c60b0a3f7595088b30a8621f280b5e4c.zip
Merge pull request #12568 from nvim-treesitter/bytetrack
Bytetrack
Diffstat (limited to 'src/nvim/lua/treesitter.c')
-rw-r--r--src/nvim/lua/treesitter.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index 9a58823d64..8be4b6f376 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -286,22 +286,21 @@ static const char *input_cb(void *payload, uint32_t byte_index,
}
char_u *line = ml_get_buf(bp, position.row+1, false);
size_t len = STRLEN(line);
-
if (position.column > len) {
*bytes_read = 0;
- } else {
- size_t tocopy = MIN(len-position.column, BUFSIZE);
-
- memcpy(buf, line+position.column, tocopy);
- // Translate embedded \n to NUL
- memchrsub(buf, '\n', '\0', tocopy);
- *bytes_read = (uint32_t)tocopy;
- if (tocopy < BUFSIZE) {
- // now add the final \n. If it didn't fit, input_cb will be called again
- // on the same line with advanced column.
- buf[tocopy] = '\n';
- (*bytes_read)++;
- }
+ return "";
+ }
+ size_t tocopy = MIN(len-position.column, BUFSIZE);
+
+ memcpy(buf, line+position.column, tocopy);
+ // Translate embedded \n to NUL
+ memchrsub(buf, '\n', '\0', tocopy);
+ *bytes_read = (uint32_t)tocopy;
+ if (tocopy < BUFSIZE) {
+ // now add the final \n. If it didn't fit, input_cb will be called again
+ // on the same line with advanced column.
+ buf[tocopy] = '\n';
+ (*bytes_read)++;
}
return buf;
#undef BUFSIZE