aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-14 04:36:44 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-06-15 04:47:23 +0800
commit53b2817fd35be22c556b356c71ea0b0676c8e230 (patch)
treedf8568736ea86ff077e7ddad08f084e9ffde2843
parente2ef5330252b3b52b816503cdcb01934b68f43a0 (diff)
downloadrneovim-53b2817fd35be22c556b356c71ea0b0676c8e230.tar.gz
rneovim-53b2817fd35be22c556b356c71ea0b0676c8e230.tar.bz2
rneovim-53b2817fd35be22c556b356c71ea0b0676c8e230.zip
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>
-rw-r--r--src/nvim/popupmenu.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index 50569fbc42..6330f37bad 100644
--- 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);
}