neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 53b2817fd35be22c556b356c71ea0b0676c8e230
parent e2ef5330252b3b52b816503cdcb01934b68f43a0
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Fri, 14 Jun 2024 04:36:44 +0800

vim-patch:9.1.0480: fuzzy string matching executed when not needed

Problem:  fuzzy string matching executed when not needed
Solution: when no leader is available, can skip fuzzy logic, so return
          early (glepnir)

closes: vim/vim#14986

https://github.com/vim/vim/commit/1c296026627d7ac8195e803b4c2393c21ae659b4

Co-authored-by: glepnir <glephunter@gmail.com>

Diffstat:
Msrc/nvim/popupmenu.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c @@ -442,23 +442,24 @@ static void pum_puts_with_attr(int col, char *text, int attr) { char *leader = ins_compl_leader(); - if ((win_hl_attr(curwin, HLF_PMSI) == win_hl_attr(curwin, HLF_PSI) - && win_hl_attr(curwin, HLF_PMNI) == win_hl_attr(curwin, HLF_PNI))) { + if (leader == NULL || *leader == NUL + || (win_hl_attr(curwin, HLF_PMSI) == win_hl_attr(curwin, HLF_PSI) + && win_hl_attr(curwin, HLF_PMNI) == win_hl_attr(curwin, HLF_PNI))) { grid_line_puts(col, text, -1, attr); return; } char *rt_leader = NULL; - if (leader != NULL && curwin->w_p_rl) { + if (curwin->w_p_rl) { rt_leader = reverse_text(leader); } char *match_leader = rt_leader != NULL ? rt_leader : leader; - size_t leader_len = match_leader ? strlen(match_leader) : 0; + size_t leader_len = strlen(match_leader); const bool in_fuzzy = (get_cot_flags() & COT_FUZZY) != 0; garray_T *ga = NULL; - if (match_leader != NULL && leader_len > 0 && in_fuzzy) { + if (in_fuzzy) { ga = fuzzy_match_str_with_pos(text, match_leader); }