aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchentau <tchen1998@gmail.com>2021-01-12 18:32:16 -0800
committerchentau <tchen1998@gmail.com>2021-01-12 18:32:16 -0800
commit2ac0ca2025746c39d10aad0e32749174b4222448 (patch)
tree3e7fb006b826bd56d1d64fc2a5757e0a9d167cb1 /src
parent61276610243d2afd14df671f164bbfba32bd9d9d (diff)
downloadrneovim-2ac0ca2025746c39d10aad0e32749174b4222448.tar.gz
rneovim-2ac0ca2025746c39d10aad0e32749174b4222448.tar.bz2
rneovim-2ac0ca2025746c39d10aad0e32749174b4222448.zip
change end_right_gravity error behavior
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/buffer.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 8faf812357..2890d89bc0 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -1449,6 +1449,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id,
VirtText virt_text = KV_INITIAL_VALUE;
bool right_gravity = true;
bool end_right_gravity = false;
+ bool end_gravity_set = false;
for (size_t i = 0; i < opts.size; i++) {
String k = opts.items[i].key;
@@ -1546,12 +1547,21 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id,
goto error;
}
end_right_gravity = v->data.boolean;
+ end_gravity_set = true;
} else {
api_set_error(err, kErrorTypeValidation, "unexpected key: %s", k.data);
goto error;
}
}
+ // Only error out if they try to set end_right_gravity without
+ // setting end_col or end_line
+ if (line2 == -1 && col2 == 0 && end_gravity_set) {
+ api_set_error(err, kErrorTypeValidation,
+ "cannot set end_right_gravity "
+ "without setting end_line or end_col");
+ }
+
if (col2 >= 0) {
if (line2 >= 0 && line2 < buf->b_ml.ml_line_count) {
len = STRLEN(ml_get_buf(buf, (linenr_T)line2 + 1, false));
@@ -1570,14 +1580,6 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id,
col2 = 0;
}
- // Only error out if they try to set end_right_gravity to true without
- // setting end_col or end_line
- if (line2 == 0 && col2 == 0 && end_right_gravity) {
- api_set_error(err, kErrorTypeValidation,
- "cannot set end_right_gravity to true "
- "without setting end_line and end_col");
- }
-
// TODO(bfredl): synergize these two branches even more
if (ephemeral && decor_state.buf == buf) {
int attr_id = hl_id > 0 ? syn_id2attr(hl_id) : 0;