mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
Merge ec8c74e8480d77f655ca1136ff530395d457a37a into a494ce1c64a2637719a5c1339abf19ec7c48089c
This commit is contained in:
commit
2ddaca9348
@ -1,4 +1,4 @@
|
||||
*builtin.txt* For Vim version 9.1. Last change: 2025 Jul 03
|
||||
*builtin.txt* For Vim version 9.1. Last change: 2025 Jul 04
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -238,8 +238,8 @@ getcharsearch() Dict last character search
|
||||
getcharstr([{expr} [, {opts}]]) String get one character from the user
|
||||
getcmdcomplpat() String return the completion pattern of the
|
||||
current command-line completion
|
||||
getcmdcompltype({pat}) String return the type of command-line
|
||||
completion
|
||||
getcmdcompltype() String return the type of the current
|
||||
command-line completion
|
||||
getcmdline() String return the current command-line input
|
||||
getcmdpos() Number return cursor position in command-line
|
||||
getcmdprompt() String return the current command-line prompt
|
||||
@ -249,6 +249,8 @@ getcmdtype() String return current command-line type
|
||||
getcmdwintype() String return current command-line window type
|
||||
getcompletion({pat}, {type} [, {filtered}])
|
||||
List list of cmdline completion matches
|
||||
getcompletiontype({pat}) String return the type of the command-line
|
||||
completion using {pat}
|
||||
getcurpos([{winnr}]) List position of the cursor
|
||||
getcursorcharpos([{winnr}]) List character position of the cursor
|
||||
getcwd([{winnr} [, {tabnr}]]) String get the current working directory
|
||||
@ -4201,16 +4203,18 @@ getcmdcomplpat() *getcmdcomplpat()*
|
||||
Return type: |String|
|
||||
|
||||
|
||||
getcmdcompltype([{pat}]) *getcmdcompltype()*
|
||||
Return the type of command-line completion using {pat}.
|
||||
If {pat} is omited, only works when the command line is being
|
||||
edited, thus requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
|
||||
|
||||
getcmdcompltype() *getcmdcompltype()*
|
||||
Return the type of the current command-line completion.
|
||||
Only works when the command line is being edited, thus
|
||||
requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
|
||||
See |:command-completion| for the return string.
|
||||
Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
|
||||
|getcmdprompt()|, |getcmdcomplpat()| and |setcmdline()|.
|
||||
Returns an empty string when completion is not defined.
|
||||
|
||||
To get the type of the command-line completion for the
|
||||
specified string, use |getcompletiontype()|.
|
||||
|
||||
Return type: |String|
|
||||
|
||||
|
||||
@ -4369,6 +4373,15 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
|
||||
<
|
||||
Return type: list<string>
|
||||
|
||||
getcompletiontype({pat}) *getcompletiontype()*
|
||||
Return the type of the command-line completion using {pat}.
|
||||
When no corresponding completion type is found, an empty
|
||||
string is returned.
|
||||
To get the current command-line completion type, use
|
||||
|getcmdcompltype()|.
|
||||
|
||||
Return type: |String|
|
||||
|
||||
*getcurpos()*
|
||||
getcurpos([{winid}])
|
||||
Get the position of the cursor. This is like getpos('.'), but
|
||||
|
@ -7976,6 +7976,7 @@ getcmdscreenpos() builtin.txt /*getcmdscreenpos()*
|
||||
getcmdtype() builtin.txt /*getcmdtype()*
|
||||
getcmdwintype() builtin.txt /*getcmdwintype()*
|
||||
getcompletion() builtin.txt /*getcompletion()*
|
||||
getcompletiontype() builtin.txt /*getcompletiontype()*
|
||||
getcurpos() builtin.txt /*getcurpos()*
|
||||
getcursorcharpos() builtin.txt /*getcursorcharpos()*
|
||||
getcwd() builtin.txt /*getcwd()*
|
||||
|
@ -1,4 +1,4 @@
|
||||
*usr_41.txt* For Vim version 9.1. Last change: 2025 Jul 03
|
||||
*usr_41.txt* For Vim version 9.1. Last change: 2025 Jul 04
|
||||
|
||||
VIM USER MANUAL - by Bram Moolenaar
|
||||
|
||||
@ -1100,7 +1100,8 @@ Buffers, windows and the argument list:
|
||||
Command line: *command-line-functions*
|
||||
getcmdcomplpat() get completion pattern of the current command
|
||||
line
|
||||
getcmdcompltype() get the type of the command line completion
|
||||
getcmdcompltype() get the type of the current command line
|
||||
completion
|
||||
getcmdline() get the current command line input
|
||||
getcmdprompt() get the current command line prompt
|
||||
getcmdpos() get position of the cursor in the command line
|
||||
@ -1111,6 +1112,8 @@ Command line: *command-line-functions*
|
||||
getcmdtype() return the current command-line type
|
||||
getcmdwintype() return the current command-line window type
|
||||
getcompletion() list of command-line completion matches
|
||||
getcompletiontype() get the type of the command-line completion
|
||||
for specified string
|
||||
fullcommand() get full command name
|
||||
cmdcomplete_info() get command-line completion information
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
*version9.txt* For Vim version 9.1. Last change: 2025 Jul 03
|
||||
*version9.txt* For Vim version 9.1. Last change: 2025 Jun 28
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -41607,8 +41607,6 @@ Completion: ~
|
||||
- allow to complete directories from 'cdpath' for |:cd| and similar commands,
|
||||
add the "cd_in_path" completion type for e.g. |:command-complete| and
|
||||
|getcompletion()|
|
||||
- |getcompletion()| now accepts a pat and returns the completion type for the
|
||||
{pat} argument
|
||||
- allow to complete shell commands and files using the new shellcmdline
|
||||
completion type using |:command-complete| and |getcmdcomplpat()|
|
||||
- allow to specify additional attributes in the completion menu (allows to
|
||||
|
@ -4556,6 +4556,35 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
|
||||
ExpandCleanup(&xpc);
|
||||
}
|
||||
|
||||
/*
|
||||
* "getcompletiontype()" function
|
||||
*/
|
||||
void
|
||||
f_getcompletiontype(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
char_u *pat;
|
||||
expand_T xpc;
|
||||
int cmdline_len;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
if (check_for_string_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
pat = tv_get_string(&argvars[0]);
|
||||
ExpandInit(&xpc);
|
||||
|
||||
cmdline_len = (int)STRLEN(pat);
|
||||
set_cmd_context(&xpc, pat, cmdline_len, cmdline_len, FALSE);
|
||||
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
|
||||
xpc.xp_col = cmdline_len;
|
||||
|
||||
rettv->vval.v_string = get_cmdline_completion(&xpc);
|
||||
|
||||
ExpandCleanup(&xpc);
|
||||
}
|
||||
|
||||
/*
|
||||
* "cmdcomplete_info()" function
|
||||
*/
|
||||
|
@ -2264,7 +2264,7 @@ static funcentry_T global_functions[] =
|
||||
ret_string, f_getcharstr},
|
||||
{"getcmdcomplpat", 0, 0, 0, NULL,
|
||||
ret_string, f_getcmdcomplpat},
|
||||
{"getcmdcompltype", 0, 1, FEARG_1, NULL,
|
||||
{"getcmdcompltype", 0, 0, 0, NULL,
|
||||
ret_string, f_getcmdcompltype},
|
||||
{"getcmdline", 0, 0, 0, NULL,
|
||||
ret_string, f_getcmdline},
|
||||
@ -2280,6 +2280,8 @@ static funcentry_T global_functions[] =
|
||||
ret_string, f_getcmdwintype},
|
||||
{"getcompletion", 2, 3, FEARG_1, arg3_string_string_bool,
|
||||
ret_list_string, f_getcompletion},
|
||||
{"getcompletiontype", 1, 1, FEARG_1, arg1_string,
|
||||
ret_string, f_getcompletiontype},
|
||||
{"getcurpos", 0, 1, FEARG_1, arg1_number,
|
||||
ret_list_number, f_getcurpos},
|
||||
{"getcursorcharpos", 0, 1, FEARG_1, arg1_number,
|
||||
|
@ -4303,9 +4303,9 @@ get_cmdline_completion_pattern(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the current command-line completion type.
|
||||
* Get the command-line completion type.
|
||||
*/
|
||||
static char_u *
|
||||
char_u *
|
||||
get_cmdline_completion(expand_T *xpc)
|
||||
{
|
||||
int xp_context;
|
||||
@ -4354,40 +4354,16 @@ f_getcmdcomplpat(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
void
|
||||
f_getcmdcompltype(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
{
|
||||
if (check_for_opt_string_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
cmdline_info_T *p;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
if (argvars[0].v_type != VAR_UNKNOWN)
|
||||
{
|
||||
char_u *pat;
|
||||
expand_T xpc;
|
||||
int cmdline_len;
|
||||
p = get_ccline_ptr();
|
||||
if (cmdline_star > 0 || p == NULL || p->xpc == NULL)
|
||||
return;
|
||||
|
||||
pat = tv_get_string(&argvars[0]);
|
||||
ExpandInit(&xpc);
|
||||
|
||||
cmdline_len = (int)STRLEN(pat);
|
||||
set_cmd_context(&xpc, pat, cmdline_len, cmdline_len, FALSE);
|
||||
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
|
||||
xpc.xp_col = cmdline_len;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = get_cmdline_completion(&xpc);
|
||||
|
||||
ExpandCleanup(&xpc);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdline_info_T *p;
|
||||
|
||||
p = get_ccline_ptr();
|
||||
if (cmdline_star > 0 || p == NULL || p->xpc == NULL)
|
||||
return;
|
||||
|
||||
rettv->vval.v_string = get_cmdline_completion(p->xpc);
|
||||
}
|
||||
rettv->vval.v_string = get_cmdline_completion(p->xpc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -24,5 +24,6 @@ int wildmenu_translate_key(cmdline_info_T *cclp, int key, expand_T *xp, int did_
|
||||
int wildmenu_process_key(cmdline_info_T *cclp, int key, expand_T *xp);
|
||||
void wildmenu_cleanup(cmdline_info_T *cclp);
|
||||
void f_getcompletion(typval_T *argvars, typval_T *rettv);
|
||||
void f_getcompletiontype(typval_T *argvars, typval_T *rettv);
|
||||
void f_cmdcomplete_info(typval_T *argvars UNUSED, typval_T *rettv);
|
||||
/* vim: set ft=c : */
|
||||
|
@ -30,6 +30,7 @@ char_u *vim_strsave_fnameescape(char_u *fname, int what);
|
||||
void escape_fname(char_u **pp);
|
||||
void tilde_replace(char_u *orig_pat, int num_files, char_u **files);
|
||||
cmdline_info_T *get_cmdline_info(void);
|
||||
char_u *get_cmdline_completion(expand_T *xpc);
|
||||
void f_getcmdcomplpat(typval_T *argvars, typval_T *rettv);
|
||||
void f_getcmdcompltype(typval_T *argvars, typval_T *rettv);
|
||||
void f_getcmdline(typval_T *argvars, typval_T *rettv);
|
||||
|
@ -877,6 +877,17 @@ func Test_getcompletion()
|
||||
call assert_fails('call getcompletion("abc", [])', 'E1174:')
|
||||
endfunc
|
||||
|
||||
func Test_getcompletiontype()
|
||||
call assert_fails('call getcompletiontype()', 'E119:')
|
||||
call assert_fails('call getcompletiontype({})', 'E1174:')
|
||||
call assert_equal(getcompletiontype(''), 'command')
|
||||
call assert_equal(getcompletiontype('dummy '), '')
|
||||
call assert_equal(getcompletiontype('cd '), 'dir_in_path')
|
||||
call assert_equal(getcompletiontype('let v:n'), 'var')
|
||||
call assert_equal(getcompletiontype('call tag'), 'function')
|
||||
call assert_equal(getcompletiontype('help '), 'help')
|
||||
endfunc
|
||||
|
||||
func Test_multibyte_expression()
|
||||
" Get a dialog in the GUI
|
||||
CheckNotGui
|
||||
@ -4589,14 +4600,4 @@ func Test_range_complete()
|
||||
set wildcharm=0
|
||||
endfunc
|
||||
|
||||
func Test_getcmdcompltype_with_pat()
|
||||
call assert_fails('call getcmdcompltype({})', 'E1174:')
|
||||
call assert_equal(getcmdcompltype(''), 'command')
|
||||
call assert_equal(getcmdcompltype('dummy '), '')
|
||||
call assert_equal(getcmdcompltype('cd '), 'dir_in_path')
|
||||
call assert_equal(getcmdcompltype('let v:n'), 'var')
|
||||
call assert_equal(getcmdcompltype('call tag'), 'function')
|
||||
call assert_equal(getcmdcompltype('help '), 'help')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Loading…
x
Reference in New Issue
Block a user