diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-06-18 05:49:33 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-06-18 06:18:34 +0800 |
commit | c429c5f86fb8286bbb28e96985d9cc212155201b (patch) | |
tree | aeb7664e95cac099e98cd9d07cace3ea254e302e /src/nvim/popupmenu.c | |
parent | b60030b7bf3e638ba134550091131fc5229b69a1 (diff) | |
download | rneovim-c429c5f86fb8286bbb28e96985d9cc212155201b.tar.gz rneovim-c429c5f86fb8286bbb28e96985d9cc212155201b.tar.bz2 rneovim-c429c5f86fb8286bbb28e96985d9cc212155201b.zip |
vim-patch:9.1.0495: Matched text isn't highlighted in cmdline pum
Problem: Matched text isn't highlighted in cmdline pum.
Solution: Use cmdline completion pattern in cmdline mode.
(zeertzjq)
closes: vim/vim#15029
https://github.com/vim/vim/commit/d8c9340fc67ca19f82ec3e77ec38296424e758cf
Cherry-pick syntax.txt change from runtime update.
Diffstat (limited to 'src/nvim/popupmenu.c')
-rw-r--r-- | src/nvim/popupmenu.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index 18446e749b..2d3c128de1 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -17,6 +17,7 @@ #include "nvim/buffer_updates.h" #include "nvim/change.h" #include "nvim/charset.h" +#include "nvim/cmdexpand.h" #include "nvim/drawscreen.h" #include "nvim/edit.h" #include "nvim/errors.h" @@ -441,17 +442,21 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, i /// Returns attributes for every cell, or NULL if all attributes are the same. static int *pum_compute_text_attrs(char *text, hlf_T hlf) { - char *leader = ins_compl_leader(); - - if (leader == NULL || *leader == NUL || (hlf != HLF_PSI && hlf != HLF_PNI) + if ((hlf != HLF_PSI && hlf != HLF_PNI) || (win_hl_attr(curwin, HLF_PMSI) == win_hl_attr(curwin, HLF_PSI) && win_hl_attr(curwin, HLF_PMNI) == win_hl_attr(curwin, HLF_PNI))) { return NULL; } + char *leader = State == MODE_CMDLINE ? cmdline_compl_pattern() : ins_compl_leader(); + if (leader == NULL || *leader == NUL) { + return NULL; + } + int *attrs = xmalloc(sizeof(int) * (size_t)vim_strsize(text)); + bool in_fuzzy = State == MODE_CMDLINE ? cmdline_compl_is_fuzzy() + : (get_cot_flags() & COT_FUZZY) != 0; size_t leader_len = strlen(leader); - const bool in_fuzzy = (get_cot_flags() & COT_FUZZY) != 0; garray_T *ga = NULL; bool matched_start = false; |