aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/buffer.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-08-29 10:03:04 +0200
committerGitHub <noreply@github.com>2023-08-29 10:03:04 +0200
commit97badc9ac41e0c90d6e4a4389c3b7c022a5dfb88 (patch)
tree196412487f11db53d78ce91c563f42158955148f /src/nvim/api/buffer.c
parentffb340bf63af42ac347e23e0488898adc4391328 (diff)
parent0a81ec14a4c006822509b06396871509140b7a79 (diff)
downloadrneovim-97badc9ac41e0c90d6e4a4389c3b7c022a5dfb88.tar.gz
rneovim-97badc9ac41e0c90d6e4a4389c3b7c022a5dfb88.tar.bz2
rneovim-97badc9ac41e0c90d6e4a4389c3b7c022a5dfb88.zip
Merge pull request #24912 from bfredl/topline2
fix(api): better topline adjustments in nvim_buf_set_lines
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r--src/nvim/api/buffer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index d36f0dd050..b8cb09ceb3 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -464,7 +464,8 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
// Adjust marks. Invalidate any which lie in the
// changed range, and move any in the remainder of the buffer.
- mark_adjust_buf(buf, (linenr_T)start, (linenr_T)(end - 1), MAXLNUM, (linenr_T)extra,
+ linenr_T adjust = end > start ? MAXLNUM : 0;
+ mark_adjust_buf(buf, (linenr_T)start, (linenr_T)(end - 1), adjust, (linenr_T)extra,
true, true, kExtmarkNOOP);
extmark_splice(buf, (int)start - 1, 0, (int)(end - start), 0,
@@ -711,7 +712,8 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
// Adjust marks. Invalidate any which lie in the
// changed range, and move any in the remainder of the buffer.
// Do not adjust any cursors. need to use column-aware logic (below)
- mark_adjust_buf(buf, (linenr_T)start_row, (linenr_T)end_row, MAXLNUM, (linenr_T)extra,
+ linenr_T adjust = end_row >= start_row ? MAXLNUM : 0;
+ mark_adjust_buf(buf, (linenr_T)start_row, (linenr_T)end_row, adjust, (linenr_T)extra,
true, true, kExtmarkNOOP);
extmark_splice(buf, (int)start_row - 1, (colnr_T)start_col,