diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-07-25 14:33:28 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2021-07-29 20:34:42 +0200 |
commit | a4d81a800293f05790025f43033de11c7bd05a7b (patch) | |
tree | d6b51480650bcb721f6a094fa527c8320c127316 /src/nvim/api/private/helpers.c | |
parent | 1495d36d63305862da3c4106455667d51b578707 (diff) | |
download | rneovim-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/private/helpers.c')
-rw-r--r-- | src/nvim/api/private/helpers.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index e78bd2ea9a..e9a436d3e3 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -1592,9 +1592,10 @@ bool extmark_get_index_from_obj(buf_T *buf, Integer ns_id, Object obj, int } } -VirtText parse_virt_text(Array chunks, Error *err) +VirtText parse_virt_text(Array chunks, Error *err, int *width) { VirtText virt_text = KV_INITIAL_VALUE; + int w = 0; for (size_t i = 0; i < chunks.size; i++) { if (chunks.items[i].type != kObjectTypeArray) { api_set_error(err, kErrorTypeValidation, "Chunk is not an array"); @@ -1635,9 +1636,12 @@ VirtText parse_virt_text(Array chunks, Error *err) } char *text = transstr(str.size > 0 ? str.data : ""); // allocates + w += (int)mb_string2cells((char_u *)text); + kv_push(virt_text, ((VirtTextChunk){ .text = text, .hl_id = hl_id })); } + *width = w; return virt_text; free_exit: |