diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-03-25 02:24:24 +0100 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2023-04-01 13:59:03 +0200 |
commit | 2a10f64e254375e77e1c5a6aeae3cd65cd122afb (patch) | |
tree | 5b3cc58c001d4a47de52796274dd7b2dcf51b0a8 /src/nvim/extmark.c | |
parent | 2257ade3dc2daab5ee12d27807c0b3bcf103cd29 (diff) | |
download | rneovim-2a10f64e254375e77e1c5a6aeae3cd65cd122afb.tar.gz rneovim-2a10f64e254375e77e1c5a6aeae3cd65cd122afb.tar.bz2 rneovim-2a10f64e254375e77e1c5a6aeae3cd65cd122afb.zip |
feat(extmarks): extend nvim_buf_get_extmarks()
Problem: Can not get all extmarks in a buffer. Properties are missing
from the details array.
Solution: Allow getting all extmarks in a buffer by supplying a -1
"ns_id". Add missing properties to the details array.
Diffstat (limited to 'src/nvim/extmark.c')
-rw-r--r-- | src/nvim/extmark.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index d385a2018f..32050c5b41 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -301,7 +301,8 @@ bool extmark_clear(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_r /// dir can be set to control the order of the array /// amount = amount of marks to find or -1 for all ExtmarkInfoArray extmark_get(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_row, - colnr_T u_col, int64_t amount, bool reverse) + colnr_T u_col, int64_t amount, bool reverse, bool all_ns, + ExtmarkType type_filter) { ExtmarkInfoArray array = KV_INITIAL_VALUE; MarkTreeIter itr[1]; @@ -320,7 +321,25 @@ ExtmarkInfoArray extmark_get(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_co goto next_mark; } - if (mark.ns == ns_id) { + uint16_t type_flags = kExtmarkNone; + if (type_filter != kExtmarkNone) { + Decoration *decor = mark.decor_full; + if (decor && (decor->sign_text || decor->number_hl_id)) { + type_flags |= kExtmarkSign; + } + if (decor && decor->virt_text.size) { + type_flags |= kExtmarkVirtText; + } + if (decor && decor->virt_lines.size) { + type_flags |= kExtmarkVirtLines; + } + if ((decor && (decor->line_hl_id || decor->cursorline_hl_id)) + || mark.hl_id) { + type_flags |= kExtmarkHighlight; + } + } + + if ((all_ns || mark.ns == ns_id) && type_flags & type_filter) { mtkey_t end = marktree_get_alt(buf->b_marktree, mark, NULL); kv_push(array, ((ExtmarkInfo) { .ns_id = mark.ns, .mark_id = mark.id, |