aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2020-09-17 22:59:20 +0200
committerGitHub <noreply@github.com>2020-09-17 22:59:20 +0200
commit2d9ae2166470b164bfce15333c85d00b93ff83f4 (patch)
treea28170094f69a841392b47f7e0fc2df73d4fe723 /src
parentd4b4335fe330bf0558d38883cb8a2b47e8ece28a (diff)
parentcecc45efb16cc30b40d4c481e6ef345614c96404 (diff)
downloadrneovim-2d9ae2166470b164bfce15333c85d00b93ff83f4.tar.gz
rneovim-2d9ae2166470b164bfce15333c85d00b93ff83f4.tar.bz2
rneovim-2d9ae2166470b164bfce15333c85d00b93ff83f4.zip
Merge pull request #12872 from nvim-treesitter/extmarks-wrong-boundcheck
Extmarks: allow to set extranges past final newline
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/buffer.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 6f74ec905c..e77870dcf3 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -1393,15 +1393,17 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id,
}
if (col2 >= 0) {
- if (line2 >= 0) {
- len = STRLEN(ml_get_buf(buf, (linenr_T)line2+1, false));
+ if (line2 >= 0 && line2 < buf->b_ml.ml_line_count) {
+ len = STRLEN(ml_get_buf(buf, (linenr_T)line2 + 1, false));
+ } else if (line2 == buf->b_ml.ml_line_count) {
+ // We are trying to add an extmark past final newline
+ len = 0;
} else {
// reuse len from before
line2 = (int)line;
}
if (col2 > (Integer)len) {
- api_set_error(err, kErrorTypeValidation,
- "end_col value outside range");
+ api_set_error(err, kErrorTypeValidation, "end_col value outside range");
goto error;
}
} else if (line2 >= 0) {