aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-18 06:45:28 +0800
committerGitHub <noreply@github.com>2024-06-18 06:45:28 +0800
commit7363b695debf6341b75337f99accfa7fcc9dbe1d (patch)
treec2f9d18c6238808e1480cf6a8bd0cd1e5aab8e42 /src
parentb60030b7bf3e638ba134550091131fc5229b69a1 (diff)
parentc2491fbab43fc506f7f902c72206d890e01688a5 (diff)
downloadrneovim-7363b695debf6341b75337f99accfa7fcc9dbe1d.tar.gz
rneovim-7363b695debf6341b75337f99accfa7fcc9dbe1d.tar.bz2
rneovim-7363b695debf6341b75337f99accfa7fcc9dbe1d.zip
Merge pull request #29379 from zeertzjq/vim-9.1.0495
vim-patch:9.1.{0495,0496}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/cmdexpand.c14
-rw-r--r--src/nvim/insexpand.c2
-rw-r--r--src/nvim/popupmenu.c16
3 files changed, 26 insertions, 6 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index f75b84c77b..9ee5cde5b2 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -402,6 +402,20 @@ void cmdline_pum_cleanup(CmdlineInfo *cclp)
wildmenu_cleanup(cclp);
}
+/// Returns the current cmdline completion pattern.
+char *cmdline_compl_pattern(void)
+{
+ expand_T *xp = get_cmdline_info()->xpc;
+ return xp == NULL ? NULL : xp->xp_orig;
+}
+
+/// Returns true if fuzzy cmdline completion is active, false otherwise.
+bool cmdline_compl_is_fuzzy(void)
+{
+ expand_T *xp = get_cmdline_info()->xpc;
+ return xp != NULL && cmdline_fuzzy_completion_supported(xp);
+}
+
/// Return the number of characters that should be skipped in the wildmenu
/// These are backslashes used for escaping. Do show backslashes in help tags.
static int skip_wildmenu_char(expand_T *xp, char *s)
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 0a25b72451..ded5c6e3c3 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -1397,7 +1397,7 @@ bool compl_match_curr_select(int selected)
/// Get current completion leader
char *ins_compl_leader(void)
{
- return compl_leader;
+ return compl_leader != NULL ? compl_leader : compl_orig_text;
}
/// Add any identifiers that match the given pattern "pat" in the list of
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index 18446e749b..8608a2c866 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,22 @@ 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;
@@ -459,7 +465,7 @@ static int *pum_compute_text_attrs(char *text, hlf_T hlf)
if (in_fuzzy) {
ga = fuzzy_match_str_with_pos(text, leader);
} else {
- matched_start = strncmp(text, leader, leader_len) == 0;
+ matched_start = mb_strnicmp(text, leader, leader_len) == 0;
}
const char *ptr = text;