aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/buffer.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-07-25 14:33:28 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2021-07-29 20:34:42 +0200
commita4d81a800293f05790025f43033de11c7bd05a7b (patch)
treed6b51480650bcb721f6a094fa527c8320c127316 /src/nvim/api/buffer.c
parent1495d36d63305862da3c4106455667d51b578707 (diff)
downloadrneovim-a4d81a800293f05790025f43033de11c7bd05a7b.tar.gz
rneovim-a4d81a800293f05790025f43033de11c7bd05a7b.tar.bz2
rneovim-a4d81a800293f05790025f43033de11c7bd05a7b.zip
refactor(decorations): merge the two different code paths for virt_text
test(bufhl): CHANGE of tested behaviour (inb4 a proper priority mechanism) test(decoration): change of test; previous behavior was buggy (ghost buffer text)
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r--src/nvim/api/buffer.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 47216996b4..56c9cfc517 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -1566,7 +1566,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id,
"virt_text is not an Array");
goto error;
}
- decor.virt_text = parse_virt_text(v->data.array, err);
+ decor.virt_text = parse_virt_text(v->data.array, err,
+ &decor.virt_text_width);
if (ERROR_SET(err)) {
goto error;
}
@@ -1949,23 +1950,26 @@ Integer nvim_buf_set_virtual_text(Buffer buffer,
}
uint64_t ns_id = src2ns(&src_id);
+ int width;
- VirtText virt_text = parse_virt_text(chunks, err);
+ VirtText virt_text = parse_virt_text(chunks, err, &width);
if (ERROR_SET(err)) {
return 0;
}
- VirtText *existing = decor_find_virttext(buf, (int)line, ns_id);
+ Decoration *existing = decor_find_virttext(buf, (int)line, ns_id);
if (existing) {
- clear_virttext(existing);
- *existing = virt_text;
+ clear_virttext(&existing->virt_text);
+ existing->virt_text = virt_text;
+ existing->virt_text_width = width;
return src_id;
}
Decoration *decor = xcalloc(1, sizeof(*decor));
decor->virt_text = virt_text;
+ decor->virt_text_width = width;
extmark_set(buf, ns_id, 0, (int)line, 0, -1, -1, decor, true,
false, kExtmarkNoUndo);