diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-11-28 11:01:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-28 11:01:21 +0100 |
commit | ba564442ae5e8793f54d401fc636194df48cad3d (patch) | |
tree | 6595afdc29f0f0a1e7057373a14e5b121e41ae41 /src/nvim/api/extmark.c | |
parent | 71e954ad303eec25b67541f3a99392446f6de8b3 (diff) | |
parent | ae3685798deaf51f14422c568998998c03f91f2c (diff) | |
download | rneovim-ba564442ae5e8793f54d401fc636194df48cad3d.tar.gz rneovim-ba564442ae5e8793f54d401fc636194df48cad3d.tar.bz2 rneovim-ba564442ae5e8793f54d401fc636194df48cad3d.zip |
Merge pull request #26249 from bfredl/concealchar
feat(decoration): allow conceal_char to be a composing char
Diffstat (limited to 'src/nvim/api/extmark.c')
-rw-r--r-- | src/nvim/api/extmark.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index 9a4dfe6788..d9e41f2448 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -18,6 +18,7 @@ #include "nvim/drawscreen.h" #include "nvim/extmark.h" #include "nvim/func_attr.h" +#include "nvim/grid.h" #include "nvim/highlight_group.h" #include "nvim/marktree.h" #include "nvim/mbyte.h" @@ -503,7 +504,6 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer DecorVirtText virt_text = DECOR_VIRT_TEXT_INIT; DecorVirtText virt_lines = DECOR_VIRT_LINES_INIT; bool has_hl = false; - String conceal_char_large = STRING_INIT; buf_T *buf = find_buffer_by_handle(buffer, err); if (!buf) { @@ -593,10 +593,11 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer has_hl = true; String c = opts->conceal; if (c.size > 0) { - if (c.size <= 4) { - memcpy(hl.conceal_char, c.data, c.size + (c.size < 4 ? 1 : 0)); - } else { - conceal_char_large = c; + int ch; + hl.conceal_char = utfc_ptr2schar_len(c.data, (int)c.size, &ch); + if (!hl.conceal_char || !vim_isprintc(ch)) { + api_set_error(err, kErrorTypeValidation, "conceal char has to be printable"); + goto error; } } } @@ -777,7 +778,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer decor_range_add_virt(&decor_state, r, c, line2, col2, decor_put_vt(virt_lines, NULL), true); } if (has_hl) { - DecorSignHighlight sh = decor_sh_from_inline(hl, conceal_char_large); + DecorSignHighlight sh = decor_sh_from_inline(hl); decor_range_add_sh(&decor_state, r, c, line2, col2, &sh, true, (uint32_t)ns_id, id); } if (sign.flags & kSHIsSign) { @@ -815,9 +816,9 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer } DecorInline decor = DECOR_INLINE_INIT; - if (decor_alloc || decor_indexed != DECOR_ID_INVALID || conceal_char_large.size) { + if (decor_alloc || decor_indexed != DECOR_ID_INVALID || schar_high(hl.conceal_char)) { if (has_hl) { - DecorSignHighlight sh = decor_sh_from_inline(hl, conceal_char_large); + DecorSignHighlight sh = decor_sh_from_inline(hl); sh.next = decor_indexed; decor_indexed = decor_put_sh(sh); } |