aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Vigouroux <tomvig38@gmail.com>2021-06-15 20:25:59 +0200
committerThomas Vigouroux <tomvig38@gmail.com>2021-06-16 20:15:47 +0200
commita85e8a186b089999c258b21fb2f7b62b58920884 (patch)
tree4608f56ea28d97ed3da4df3cef6a1817b715b192 /src
parent6a77def1ee05d4e4eceddb559bc779cd9b805614 (diff)
downloadrneovim-a85e8a186b089999c258b21fb2f7b62b58920884.tar.gz
rneovim-a85e8a186b089999c258b21fb2f7b62b58920884.tar.bz2
rneovim-a85e8a186b089999c258b21fb2f7b62b58920884.zip
perf(extmarks): allow ephemeral extmarks past EOF
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/buffer.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index f84e8c99a4..b371c08d2a 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -1489,21 +1489,6 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id,
return 0;
}
- size_t len = 0;
- if (line < 0 || line > buf->b_ml.ml_line_count) {
- api_set_error(err, kErrorTypeValidation, "line value outside range");
- return 0;
- } else if (line < buf->b_ml.ml_line_count) {
- len = STRLEN(ml_get_buf(buf, (linenr_T)line+1, false));
- }
-
- if (col == -1) {
- col = (Integer)len;
- } else if (col < -1 || col > (Integer)len) {
- api_set_error(err, kErrorTypeValidation, "col value outside range");
- return 0;
- }
-
bool ephemeral = false;
uint64_t id = 0;
@@ -1674,6 +1659,22 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id,
}
}
+ size_t len = 0;
+ if (line < 0 || line > buf->b_ml.ml_line_count) {
+ api_set_error(err, kErrorTypeValidation, "line value outside range");
+ return 0;
+ } else if (line < buf->b_ml.ml_line_count) {
+ len = ephemeral ? MAXCOL : STRLEN(ml_get_buf(buf, (linenr_T)line+1, false));
+ }
+
+ if (col == -1) {
+ col = (Integer)len;
+ } else if (col < -1 || col > (Integer)len) {
+ api_set_error(err, kErrorTypeValidation, "col value outside range");
+ return 0;
+ }
+
+
// Only error out if they try to set end_right_gravity without
// setting end_col or end_line
if (line2 == -1 && col2 == -1 && end_gravity_set) {
@@ -1684,7 +1685,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id,
if (col2 >= 0) {
if (line2 >= 0 && line2 < buf->b_ml.ml_line_count) {
- len = STRLEN(ml_get_buf(buf, (linenr_T)line2 + 1, false));
+ len = ephemeral ? MAXCOL : 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;