mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 06:16:08 +00:00
vim-patch:9.1.0770: current command line completion is a bit limited (#30728)
Problem: current command completion is a bit limited
Solution: Add the shellcmdline completion type and getmdcomplpat()
function (Ruslan Russkikh).
closes: vim/vim#15823
0407d621bb
Co-authored-by: Ruslan Russkikh <dvrussk@yandex.ru>
This commit is contained in:
@@ -4086,14 +4086,44 @@ static char *get_cmdline_str(void)
|
||||
return xstrnsave(p->cmdbuff, (size_t)p->cmdlen);
|
||||
}
|
||||
|
||||
/// Get the current command-line completion pattern.
|
||||
static char *get_cmdline_completion_pattern(void)
|
||||
{
|
||||
if (cmdline_star > 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CmdlineInfo *p = get_ccline_ptr();
|
||||
if (p == NULL || p->xpc == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int xp_context = p->xpc->xp_context;
|
||||
if (xp_context == EXPAND_NOTHING) {
|
||||
set_expand_context(p->xpc);
|
||||
xp_context = p->xpc->xp_context;
|
||||
p->xpc->xp_context = EXPAND_NOTHING;
|
||||
}
|
||||
if (xp_context == EXPAND_UNSUCCESSFUL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *compl_pat = p->xpc->xp_pattern;
|
||||
if (compl_pat == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return xstrdup(compl_pat);
|
||||
}
|
||||
|
||||
/// Get the current command-line completion type.
|
||||
static char *get_cmdline_completion(void)
|
||||
{
|
||||
if (cmdline_star > 0) {
|
||||
return NULL;
|
||||
}
|
||||
CmdlineInfo *p = get_ccline_ptr();
|
||||
|
||||
CmdlineInfo *p = get_ccline_ptr();
|
||||
if (p == NULL || p->xpc == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -4123,6 +4153,13 @@ static char *get_cmdline_completion(void)
|
||||
return xstrdup(cmd_compl);
|
||||
}
|
||||
|
||||
/// "getcmdcomplpat()" function
|
||||
void f_getcmdcomplpat(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = get_cmdline_completion_pattern();
|
||||
}
|
||||
|
||||
/// "getcmdcompltype()" function
|
||||
void f_getcmdcompltype(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
|
Reference in New Issue
Block a user