aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIbby <33922797+SleepySwords@users.noreply.github.com>2023-03-19 18:32:44 +1100
committerbfredl <bjorn.linse@gmail.com>2023-05-22 13:49:42 +0200
commit0e1f3b5acf74e82ea778f3c0871a804a9ae89d4e (patch)
tree3293bdfa570ae4d325ed6e8051bb6db5bb70ca8e /src
parenta38d7f99845d6ef566b2885737b892c660749d5e (diff)
downloadrneovim-0e1f3b5acf74e82ea778f3c0871a804a9ae89d4e.tar.gz
rneovim-0e1f3b5acf74e82ea778f3c0871a804a9ae89d4e.tar.bz2
rneovim-0e1f3b5acf74e82ea778f3c0871a804a9ae89d4e.zip
vim-patch:9.0.0130: cursor position wrong when inserting around virtual text
Problem: Cursor position wrong when inserting around virtual text. Solution: Update the cursor position properly. https://github.com/vim/vim/commit/1f4ee19eefecd8f70b7cbe8ee9db8ace6352e23e Co-authored-by: tom-anders <13141438+tom-anders@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer_defs.h1
-rw-r--r--src/nvim/decoration.c4
-rw-r--r--src/nvim/edit.c4
-rw-r--r--src/nvim/extmark.c3
4 files changed, 10 insertions, 2 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index f8b26d9d16..f3f98bbd17 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -808,6 +808,7 @@ struct file_buffer {
MarkTree b_marktree[1];
Map(uint32_t, uint32_t) b_extmark_ns[1]; // extmark namespaces
+ size_t b_virt_text_inline; // number of inline virtual texts
size_t b_virt_line_blocks; // number of virt_line blocks
size_t b_signs; // number of sign extmarks
size_t b_signs_with_text; // number of sign extmarks with text
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 87e4441f32..ec11c20b3e 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -95,6 +95,10 @@ void decor_remove(buf_T *buf, int row, int row2, Decoration *decor)
{
decor_redraw(buf, row, row2, decor);
if (decor) {
+ if (kv_size(decor->virt_text) && decor->virt_text_pos == kVTInline) {
+ assert(buf->b_virt_text_inline > 0);
+ buf->b_virt_text_inline--;
+ }
if (kv_size(decor->virt_lines)) {
assert(buf->b_virt_line_blocks > 0);
buf->b_virt_line_blocks--;
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index e3321a8b99..a25387f5a6 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -232,7 +232,7 @@ static void insert_enter(InsertState *s)
stop_insert_mode = false;
// need to position cursor again when on a TAB
- if (gchar_cursor() == TAB) {
+ if (gchar_cursor() == TAB || curbuf->b_virt_text_inline > 0) {
curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
}
@@ -3471,7 +3471,7 @@ static bool ins_esc(long *count, int cmdchar, bool nomove)
State = MODE_NORMAL;
may_trigger_modechanged();
// need to position cursor again when on a TAB
- if (gchar_cursor() == TAB) {
+ if (gchar_cursor() == TAB || curbuf->b_virt_text_inline > 0) {
curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
}
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index acdc36f9c7..f4a6a02682 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -148,6 +148,9 @@ revised:
}
if (decor) {
+ if (kv_size(decor->virt_text) && decor->virt_text_pos == kVTInline) {
+ buf->b_virt_text_inline++;
+ }
if (kv_size(decor->virt_lines)) {
buf->b_virt_line_blocks++;
}