mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
commit
052ced4954
@ -1970,11 +1970,11 @@ and({expr}, {expr}) Number bitwise AND
|
|||||||
api_info() Dict api metadata
|
api_info() Dict api metadata
|
||||||
append({lnum}, {string}) Number append {string} below line {lnum}
|
append({lnum}, {string}) Number append {string} below line {lnum}
|
||||||
append({lnum}, {list}) Number append lines {list} below line {lnum}
|
append({lnum}, {list}) Number append lines {list} below line {lnum}
|
||||||
argc() Number number of files in the argument list
|
argc([{winid}]) Number number of files in the argument list
|
||||||
argidx() Number current index in the argument list
|
argidx() Number current index in the argument list
|
||||||
arglistid([{winnr} [, {tabnr}]]) Number argument list id
|
arglistid([{winnr} [, {tabnr}]]) Number argument list id
|
||||||
argv({nr}) String {nr} entry of the argument list
|
argv({nr} [, {winid}]) String {nr} entry of the argument list
|
||||||
argv() List the argument list
|
argv([-1, {winid}]) List the argument list
|
||||||
assert_equal({exp}, {act} [, {msg}])
|
assert_equal({exp}, {act} [, {msg}])
|
||||||
none assert {exp} is equal to {act}
|
none assert {exp} is equal to {act}
|
||||||
assert_exception({error} [, {msg}])
|
assert_exception({error} [, {msg}])
|
||||||
@ -2446,8 +2446,15 @@ append({lnum}, {text}) *append()*
|
|||||||
:let failed = append(0, ["Chapter 1", "the beginning"])
|
:let failed = append(0, ["Chapter 1", "the beginning"])
|
||||||
<
|
<
|
||||||
*argc()*
|
*argc()*
|
||||||
argc() The result is the number of files in the argument list of the
|
argc([{winid}])
|
||||||
current window. See |arglist|.
|
The result is the number of files in the argument list. See
|
||||||
|
|arglist|.
|
||||||
|
If {winid} is not supplied, the argument list of the current
|
||||||
|
window is used.
|
||||||
|
If {winid} is -1, the global argument list is used.
|
||||||
|
Otherwise {winid} specifies the window of which the argument
|
||||||
|
list is used: either the window number or the window ID.
|
||||||
|
Returns -1 if the {winid} argument is invalid.
|
||||||
|
|
||||||
*argidx()*
|
*argidx()*
|
||||||
argidx() The result is the current index in the argument list. 0 is
|
argidx() The result is the current index in the argument list. 0 is
|
||||||
@ -2458,7 +2465,7 @@ arglistid([{winnr} [, {tabnr}]])
|
|||||||
Return the argument list ID. This is a number which
|
Return the argument list ID. This is a number which
|
||||||
identifies the argument list being used. Zero is used for the
|
identifies the argument list being used. Zero is used for the
|
||||||
global argument list. See |arglist|.
|
global argument list. See |arglist|.
|
||||||
Return -1 if the arguments are invalid.
|
Returns -1 if the arguments are invalid.
|
||||||
|
|
||||||
Without arguments use the current window.
|
Without arguments use the current window.
|
||||||
With {winnr} only use this window in the current tab page.
|
With {winnr} only use this window in the current tab page.
|
||||||
@ -2467,17 +2474,19 @@ arglistid([{winnr} [, {tabnr}]])
|
|||||||
{winnr} can be the window number or the |window-ID|.
|
{winnr} can be the window number or the |window-ID|.
|
||||||
|
|
||||||
*argv()*
|
*argv()*
|
||||||
argv([{nr}]) The result is the {nr}th file in the argument list of the
|
argv([{nr} [, {winid}])
|
||||||
current window. See |arglist|. "argv(0)" is the first one.
|
The result is the {nr}th file in the argument list. See
|
||||||
Example: >
|
|arglist|. "argv(0)" is the first one. Example: >
|
||||||
:let i = 0
|
:let i = 0
|
||||||
:while i < argc()
|
:while i < argc()
|
||||||
: let f = escape(fnameescape(argv(i)), '.')
|
: let f = escape(fnameescape(argv(i)), '.')
|
||||||
: exe 'amenu Arg.' . f . ' :e ' . f . '<CR>'
|
: exe 'amenu Arg.' . f . ' :e ' . f . '<CR>'
|
||||||
: let i = i + 1
|
: let i = i + 1
|
||||||
:endwhile
|
:endwhile
|
||||||
< Without the {nr} argument a |List| with the whole |arglist| is
|
< Without the {nr} argument, or when {nr} is -1, a |List| with
|
||||||
returned.
|
the whole |arglist| is returned.
|
||||||
|
|
||||||
|
The {winid} argument specifies the window ID, see |argc()|.
|
||||||
|
|
||||||
*assert_equal()*
|
*assert_equal()*
|
||||||
assert_equal({expected}, {actual}, [, {msg}])
|
assert_equal({expected}, {actual}, [, {msg}])
|
||||||
@ -5554,7 +5563,7 @@ match({expr}, {pat} [, {start} [, {count}]]) *match()*
|
|||||||
the pattern. 'smartcase' is NOT used. The matching is always
|
the pattern. 'smartcase' is NOT used. The matching is always
|
||||||
done like 'magic' is set and 'cpoptions' is empty.
|
done like 'magic' is set and 'cpoptions' is empty.
|
||||||
|
|
||||||
*matchadd()* *E798* *E799* *E801*
|
*matchadd()* *E798* *E799* *E801* *E957*
|
||||||
matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]])
|
matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]])
|
||||||
Defines a pattern to be highlighted in the current window (a
|
Defines a pattern to be highlighted in the current window (a
|
||||||
"match"). It will be highlighted with {group}. Returns an
|
"match"). It will be highlighted with {group}. Returns an
|
||||||
@ -5593,6 +5602,8 @@ matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]])
|
|||||||
conceal Special character to show instead of the
|
conceal Special character to show instead of the
|
||||||
match (only for |hl-Conceal| highlighed
|
match (only for |hl-Conceal| highlighed
|
||||||
matches, see |:syn-cchar|)
|
matches, see |:syn-cchar|)
|
||||||
|
window Instead of the current window use the
|
||||||
|
window with this number or window ID.
|
||||||
|
|
||||||
The number of matches is not limited, as it is the case with
|
The number of matches is not limited, as it is the case with
|
||||||
the |:match| commands.
|
the |:match| commands.
|
||||||
|
188
src/nvim/eval.c
188
src/nvim/eval.c
@ -6662,12 +6662,24 @@ static void f_append(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
rettv->vval.v_number = 1; /* Failed */
|
rettv->vval.v_number = 1; /* Failed */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* "argc()" function
|
|
||||||
*/
|
|
||||||
static void f_argc(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_argc(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
rettv->vval.v_number = ARGCOUNT;
|
if (argvars[0].v_type == VAR_UNKNOWN) {
|
||||||
|
// use the current window
|
||||||
|
rettv->vval.v_number = ARGCOUNT;
|
||||||
|
} else if (argvars[0].v_type == VAR_NUMBER
|
||||||
|
&& tv_get_number(&argvars[0]) == -1) {
|
||||||
|
// use the global argument list
|
||||||
|
rettv->vval.v_number = GARGCOUNT;
|
||||||
|
} else {
|
||||||
|
// use the argument list of the specified window
|
||||||
|
win_T *wp = find_win_by_nr_or_id(&argvars[0]);
|
||||||
|
if (wp != NULL) {
|
||||||
|
rettv->vval.v_number = WARGCOUNT(wp);
|
||||||
|
} else {
|
||||||
|
rettv->vval.v_number = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6688,28 +6700,54 @@ static void f_arglistid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the argument list for a given window
|
||||||
|
static void get_arglist_as_rettv(aentry_T *arglist, int argcount,
|
||||||
|
typval_T *rettv)
|
||||||
|
{
|
||||||
|
tv_list_alloc_ret(rettv, argcount);
|
||||||
|
if (arglist != NULL) {
|
||||||
|
for (int idx = 0; idx < argcount; idx++) {
|
||||||
|
tv_list_append_string(rettv->vval.v_list,
|
||||||
|
(const char *)alist_name(&arglist[idx]), -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "argv(nr)" function
|
* "argv(nr)" function
|
||||||
*/
|
*/
|
||||||
static void f_argv(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_argv(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
int idx;
|
aentry_T *arglist = NULL;
|
||||||
|
int argcount = -1;
|
||||||
|
|
||||||
if (argvars[0].v_type != VAR_UNKNOWN) {
|
if (argvars[0].v_type != VAR_UNKNOWN) {
|
||||||
idx = (int)tv_get_number_chk(&argvars[0], NULL);
|
if (argvars[1].v_type == VAR_UNKNOWN) {
|
||||||
if (idx >= 0 && idx < ARGCOUNT) {
|
arglist = ARGLIST;
|
||||||
rettv->vval.v_string = (char_u *)xstrdup(
|
argcount = ARGCOUNT;
|
||||||
(const char *)alist_name(&ARGLIST[idx]));
|
} else if (argvars[1].v_type == VAR_NUMBER
|
||||||
|
&& tv_get_number(&argvars[1]) == -1) {
|
||||||
|
arglist = GARGLIST;
|
||||||
|
argcount = GARGCOUNT;
|
||||||
} else {
|
} else {
|
||||||
rettv->vval.v_string = NULL;
|
win_T *wp = find_win_by_nr_or_id(&argvars[1]);
|
||||||
|
if (wp != NULL) {
|
||||||
|
// Use the argument list of the specified window
|
||||||
|
arglist = WARGLIST(wp);
|
||||||
|
argcount = WARGCOUNT(wp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
} else {
|
rettv->vval.v_string = NULL;
|
||||||
tv_list_alloc_ret(rettv, ARGCOUNT);
|
int idx = tv_get_number_chk(&argvars[0], NULL);
|
||||||
for (idx = 0; idx < ARGCOUNT; idx++) {
|
if (arglist != NULL && idx >= 0 && idx < argcount) {
|
||||||
tv_list_append_string(rettv->vval.v_list,
|
rettv->vval.v_string = (char_u *)xstrdup(
|
||||||
(const char *)alist_name(&ARGLIST[idx]), -1);
|
(const char *)alist_name(&arglist[idx]));
|
||||||
|
} else if (idx == -1) {
|
||||||
|
get_arglist_as_rettv(arglist, argcount, rettv);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
get_arglist_as_rettv(ARGLIST, ARGCOUNT, rettv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8219,6 +8257,19 @@ static void f_exepath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
rettv->vval.v_string = path;
|
rettv->vval.v_string = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Find a window: When using a Window ID in any tab page, when using a number
|
||||||
|
/// in the current tab page.
|
||||||
|
win_T * find_win_by_nr_or_id(typval_T *vp)
|
||||||
|
{
|
||||||
|
int nr = (int)tv_get_number_chk(vp, NULL);
|
||||||
|
|
||||||
|
if (nr >= LOWEST_WIN_ID) {
|
||||||
|
return win_id2wp(vp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return find_win_by_nr(vp, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "exists()" function
|
* "exists()" function
|
||||||
*/
|
*/
|
||||||
@ -10025,7 +10076,7 @@ static void get_qf_loc_list(int is_qf, win_T *wp, typval_T *what_arg,
|
|||||||
/// "getloclist()" function
|
/// "getloclist()" function
|
||||||
static void f_getloclist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_getloclist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
win_T *wp = find_win_by_nr(&argvars[0], NULL);
|
win_T *wp = find_win_by_nr_or_id(&argvars[0]);
|
||||||
get_qf_loc_list(false, wp, &argvars[1], rettv);
|
get_qf_loc_list(false, wp, &argvars[1], rettv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10396,7 +10447,7 @@ static void f_getwininfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
static void f_win_screenpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_win_screenpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
tv_list_alloc_ret(rettv, 2);
|
tv_list_alloc_ret(rettv, 2);
|
||||||
const win_T *const wp = find_win_by_nr(&argvars[0], NULL);
|
const win_T *const wp = find_win_by_nr_or_id(&argvars[0]);
|
||||||
tv_list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_winrow + 1);
|
tv_list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_winrow + 1);
|
||||||
tv_list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_wincol + 1);
|
tv_list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_wincol + 1);
|
||||||
}
|
}
|
||||||
@ -11205,7 +11256,6 @@ static void f_index(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
|
|
||||||
static int inputsecret_flag = 0;
|
static int inputsecret_flag = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is used by f_input() and f_inputdialog() functions. The third
|
* This function is used by f_input() and f_inputdialog() functions. The third
|
||||||
* argument to f_input() specifies the type of completion to use at the
|
* argument to f_input() specifies the type of completion to use at the
|
||||||
@ -12528,6 +12578,31 @@ static void f_match(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
find_some_match(argvars, rettv, kSomeMatch);
|
find_some_match(argvars, rettv, kSomeMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int matchadd_dict_arg(typval_T *tv, const char **conceal_char,
|
||||||
|
win_T **win)
|
||||||
|
{
|
||||||
|
dictitem_T *di;
|
||||||
|
|
||||||
|
if (tv->v_type != VAR_DICT) {
|
||||||
|
EMSG(_(e_dictreq));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((di = tv_dict_find(tv->vval.v_dict, S_LEN("conceal"))) != NULL) {
|
||||||
|
*conceal_char = tv_get_string(&di->di_tv);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((di = tv_dict_find(tv->vval.v_dict, S_LEN("window"))) != NULL) {
|
||||||
|
*win = find_win_by_nr_or_id(&di->di_tv);
|
||||||
|
if (*win == NULL) {
|
||||||
|
EMSG(_("E957: Invalid window number"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "matchadd()" function
|
* "matchadd()" function
|
||||||
*/
|
*/
|
||||||
@ -12541,6 +12616,7 @@ static void f_matchadd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
int id = -1;
|
int id = -1;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
const char *conceal_char = NULL;
|
const char *conceal_char = NULL;
|
||||||
|
win_T *win = curwin;
|
||||||
|
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
|
|
||||||
@ -12551,16 +12627,9 @@ static void f_matchadd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
prio = tv_get_number_chk(&argvars[2], &error);
|
prio = tv_get_number_chk(&argvars[2], &error);
|
||||||
if (argvars[3].v_type != VAR_UNKNOWN) {
|
if (argvars[3].v_type != VAR_UNKNOWN) {
|
||||||
id = tv_get_number_chk(&argvars[3], &error);
|
id = tv_get_number_chk(&argvars[3], &error);
|
||||||
if (argvars[4].v_type != VAR_UNKNOWN) {
|
if (argvars[4].v_type != VAR_UNKNOWN
|
||||||
if (argvars[4].v_type != VAR_DICT) {
|
&& matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL) {
|
||||||
EMSG(_(e_dictreq));
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
dictitem_T *di;
|
|
||||||
if ((di = tv_dict_find(argvars[4].vval.v_dict, S_LEN("conceal")))
|
|
||||||
!= NULL) {
|
|
||||||
conceal_char = tv_get_string(&di->di_tv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12572,8 +12641,7 @@ static void f_matchadd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rettv->vval.v_number = match_add(curwin, grp, pat, prio, id, NULL,
|
rettv->vval.v_number = match_add(win, grp, pat, prio, id, NULL, conceal_char);
|
||||||
conceal_char);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
@ -12601,21 +12669,15 @@ static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
int prio = 10;
|
int prio = 10;
|
||||||
int id = -1;
|
int id = -1;
|
||||||
const char *conceal_char = NULL;
|
const char *conceal_char = NULL;
|
||||||
|
win_T *win = curwin;
|
||||||
|
|
||||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||||
prio = tv_get_number_chk(&argvars[2], &error);
|
prio = tv_get_number_chk(&argvars[2], &error);
|
||||||
if (argvars[3].v_type != VAR_UNKNOWN) {
|
if (argvars[3].v_type != VAR_UNKNOWN) {
|
||||||
id = tv_get_number_chk(&argvars[3], &error);
|
id = tv_get_number_chk(&argvars[3], &error);
|
||||||
if (argvars[4].v_type != VAR_UNKNOWN) {
|
if (argvars[4].v_type != VAR_UNKNOWN
|
||||||
if (argvars[4].v_type != VAR_DICT) {
|
&& matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL) {
|
||||||
EMSG(_(e_dictreq));
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
dictitem_T *di;
|
|
||||||
if ((di = tv_dict_find(argvars[4].vval.v_dict, S_LEN("conceal")))
|
|
||||||
!= NULL) {
|
|
||||||
conceal_char = tv_get_string(&di->di_tv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12629,8 +12691,7 @@ static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rettv->vval.v_number = match_add(curwin, group, NULL, prio, id, l,
|
rettv->vval.v_number = match_add(win, group, NULL, prio, id, l, conceal_char);
|
||||||
conceal_char);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -14806,7 +14867,7 @@ static void f_setloclist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
|
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
|
|
||||||
win = find_win_by_nr(&argvars[0], NULL);
|
win = find_win_by_nr_or_id(&argvars[0]);
|
||||||
if (win != NULL) {
|
if (win != NULL) {
|
||||||
set_qf_ll_list(win, &argvars[1], rettv);
|
set_qf_ll_list(win, &argvars[1], rettv);
|
||||||
}
|
}
|
||||||
@ -16656,7 +16717,6 @@ static void f_tabpagebuflist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "tabpagenr()" function
|
* "tabpagenr()" function
|
||||||
*/
|
*/
|
||||||
@ -16737,7 +16797,6 @@ static void f_tabpagewinnr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
rettv->vval.v_number = nr;
|
rettv->vval.v_number = nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "tagfiles()" function
|
* "tagfiles()" function
|
||||||
*/
|
*/
|
||||||
@ -17557,18 +17616,15 @@ static void f_win_id2win(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
rettv->vval.v_number = win_id2win(argvars);
|
rettv->vval.v_number = win_id2win(argvars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// "winbufnr(nr)" function
|
||||||
* "winbufnr(nr)" function
|
|
||||||
*/
|
|
||||||
static void f_winbufnr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_winbufnr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
win_T *wp = find_win_by_nr_or_id(&argvars[0]);
|
||||||
|
if (wp == NULL) {
|
||||||
wp = find_win_by_nr(&argvars[0], NULL);
|
|
||||||
if (wp == NULL)
|
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
else
|
} else {
|
||||||
rettv->vval.v_number = wp->w_buffer->b_fnum;
|
rettv->vval.v_number = wp->w_buffer->b_fnum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -17580,18 +17636,15 @@ static void f_wincol(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
rettv->vval.v_number = curwin->w_wcol + 1;
|
rettv->vval.v_number = curwin->w_wcol + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// "winheight(nr)" function
|
||||||
* "winheight(nr)" function
|
|
||||||
*/
|
|
||||||
static void f_winheight(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_winheight(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
win_T *wp = find_win_by_nr_or_id(&argvars[0]);
|
||||||
|
if (wp == NULL) {
|
||||||
wp = find_win_by_nr(&argvars[0], NULL);
|
|
||||||
if (wp == NULL)
|
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
else
|
} else {
|
||||||
rettv->vval.v_number = wp->w_height;
|
rettv->vval.v_number = wp->w_height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -17855,18 +17908,15 @@ static char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// "winwidth(nr)" function
|
||||||
* "winwidth(nr)" function
|
|
||||||
*/
|
|
||||||
static void f_winwidth(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_winwidth(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
win_T *wp = find_win_by_nr_or_id(&argvars[0]);
|
||||||
|
if (wp == NULL) {
|
||||||
wp = find_win_by_nr(&argvars[0], NULL);
|
|
||||||
if (wp == NULL)
|
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
else
|
} else {
|
||||||
rettv->vval.v_number = wp->w_width;
|
rettv->vval.v_number = wp->w_width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "wordcount()" function
|
/// "wordcount()" function
|
||||||
|
@ -240,13 +240,53 @@ func Test_arglistid()
|
|||||||
call assert_equal(0, arglistid())
|
call assert_equal(0, arglistid())
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for argv()
|
" Tests for argv() and argc()
|
||||||
func Test_argv()
|
func Test_argv()
|
||||||
call Reset_arglist()
|
call Reset_arglist()
|
||||||
call assert_equal([], argv())
|
call assert_equal([], argv())
|
||||||
call assert_equal("", argv(2))
|
call assert_equal("", argv(2))
|
||||||
|
call assert_equal(0, argc())
|
||||||
argadd a b c d
|
argadd a b c d
|
||||||
|
call assert_equal(4, argc())
|
||||||
call assert_equal('c', argv(2))
|
call assert_equal('c', argv(2))
|
||||||
|
|
||||||
|
let w1_id = win_getid()
|
||||||
|
split
|
||||||
|
let w2_id = win_getid()
|
||||||
|
arglocal
|
||||||
|
args e f g
|
||||||
|
tabnew
|
||||||
|
let w3_id = win_getid()
|
||||||
|
split
|
||||||
|
let w4_id = win_getid()
|
||||||
|
argglobal
|
||||||
|
tabfirst
|
||||||
|
call assert_equal(4, argc(w1_id))
|
||||||
|
call assert_equal('b', argv(1, w1_id))
|
||||||
|
call assert_equal(['a', 'b', 'c', 'd'], argv(-1, w1_id))
|
||||||
|
|
||||||
|
call assert_equal(3, argc(w2_id))
|
||||||
|
call assert_equal('f', argv(1, w2_id))
|
||||||
|
call assert_equal(['e', 'f', 'g'], argv(-1, w2_id))
|
||||||
|
|
||||||
|
call assert_equal(3, argc(w3_id))
|
||||||
|
call assert_equal('e', argv(0, w3_id))
|
||||||
|
call assert_equal(['e', 'f', 'g'], argv(-1, w3_id))
|
||||||
|
|
||||||
|
call assert_equal(4, argc(w4_id))
|
||||||
|
call assert_equal('c', argv(2, w4_id))
|
||||||
|
call assert_equal(['a', 'b', 'c', 'd'], argv(-1, w4_id))
|
||||||
|
|
||||||
|
call assert_equal(4, argc(-1))
|
||||||
|
call assert_equal(3, argc())
|
||||||
|
call assert_equal('d', argv(3, -1))
|
||||||
|
call assert_equal(['a', 'b', 'c', 'd'], argv(-1, -1))
|
||||||
|
tabonly | only | enew!
|
||||||
|
" Negative test cases
|
||||||
|
call assert_equal(-1, argc(100))
|
||||||
|
call assert_equal('', argv(1, 100))
|
||||||
|
call assert_equal([], argv(-1, 100))
|
||||||
|
call assert_equal('', argv(10, -1))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for the :argedit command
|
" Test for the :argedit command
|
||||||
|
@ -202,6 +202,28 @@ func Test_matchaddpos()
|
|||||||
set hlsearch&
|
set hlsearch&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_matchaddpos_otherwin()
|
||||||
|
syntax on
|
||||||
|
new
|
||||||
|
call setline(1, ['12345', 'NP'])
|
||||||
|
let winid = win_getid()
|
||||||
|
|
||||||
|
wincmd w
|
||||||
|
call matchadd('Search', '4', 10, -1, {'window': winid})
|
||||||
|
call matchaddpos('Error', [[1,2], [2,2]], 10, -1, {'window': winid})
|
||||||
|
redraw!
|
||||||
|
call assert_notequal(screenattr(1,2), 0)
|
||||||
|
call assert_notequal(screenattr(1,4), 0)
|
||||||
|
call assert_notequal(screenattr(2,2), 0)
|
||||||
|
call assert_equal(screenattr(1,2), screenattr(2,2))
|
||||||
|
call assert_notequal(screenattr(1,2), screenattr(1,4))
|
||||||
|
|
||||||
|
wincmd w
|
||||||
|
bwipe!
|
||||||
|
call clearmatches()
|
||||||
|
syntax off
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_matchaddpos_using_negative_priority()
|
func Test_matchaddpos_using_negative_priority()
|
||||||
set hlsearch
|
set hlsearch
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user