Merge pull request #13151 from janlazo/vim-8.2.1892

vim-patch:8.1.1260,8.2.{87,393,506,618,1102,1892,1896,1899,1901}
This commit is contained in:
Jan Edmund Lazo 2020-10-25 13:54:57 -04:00 committed by GitHub
commit c984a888b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 28 deletions

View File

@ -2994,7 +2994,6 @@ char_u *get_user_var_name(expand_T *xp, int idx)
static size_t tdone; static size_t tdone;
static size_t vidx; static size_t vidx;
static hashitem_T *hi; static hashitem_T *hi;
hashtab_T *ht;
if (idx == 0) { if (idx == 0) {
gdone = bdone = wdone = vidx = 0; gdone = bdone = wdone = vidx = 0;
@ -3015,7 +3014,10 @@ char_u *get_user_var_name(expand_T *xp, int idx)
} }
// b: variables // b: variables
ht = &curbuf->b_vars->dv_hashtab; // In cmdwin, the alternative buffer should be used.
hashtab_T *ht = (cmdwin_type != 0 && get_cmdline_type() == NUL)
? &prevwin->w_buffer->b_vars->dv_hashtab
: &curbuf->b_vars->dv_hashtab;
if (bdone < ht->ht_used) { if (bdone < ht->ht_used) {
if (bdone++ == 0) if (bdone++ == 0)
hi = ht->ht_array; hi = ht->ht_array;
@ -3027,7 +3029,10 @@ char_u *get_user_var_name(expand_T *xp, int idx)
} }
// w: variables // w: variables
ht = &curwin->w_vars->dv_hashtab; // In cmdwin, the alternative window should be used.
ht = (cmdwin_type != 0 && get_cmdline_type() == NUL)
? &prevwin->w_vars->dv_hashtab
: &curwin->w_vars->dv_hashtab;
if (wdone < ht->ht_used) { if (wdone < ht->ht_used) {
if (wdone++ == 0) if (wdone++ == 0)
hi = ht->ht_array; hi = ht->ht_array;

View File

@ -8147,15 +8147,17 @@ static void f_setline(typval_T *argvars, typval_T *rettv, FunPtr fptr)
/// Create quickfix/location list from VimL values /// Create quickfix/location list from VimL values
/// ///
/// Used by `setqflist()` and `setloclist()` functions. Accepts invalid /// Used by `setqflist()` and `setloclist()` functions. Accepts invalid
/// list_arg, action_arg and what_arg arguments in which case errors out, /// args argument in which case errors out, including VAR_UNKNOWN parameters.
/// including VAR_UNKNOWN parameters.
/// ///
/// @param[in,out] wp Window to create location list for. May be NULL in /// @param[in,out] wp Window to create location list for. May be NULL in
/// which case quickfix list will be created. /// which case quickfix list will be created.
/// @param[in] list_arg Quickfix list contents. /// @param[in] args [list, action, what]
/// @param[in] action_arg Action to perform: append to an existing list, /// @param[in] args[0] Quickfix list contents.
/// replace its content or create a new one. /// @param[in] args[1] Optional. Action to perform:
/// @param[in] title_arg New list title. Defaults to caller function name. /// append to an existing list, replace its content,
/// or create a new one.
/// @param[in] args[2] Optional. Quickfix list properties or title.
/// Defaults to caller function name.
/// @param[out] rettv Return value: 0 in case of success, -1 otherwise. /// @param[out] rettv Return value: 0 in case of success, -1 otherwise.
static void set_qf_ll_list(win_T *wp, typval_T *args, typval_T *rettv) static void set_qf_ll_list(win_T *wp, typval_T *args, typval_T *rettv)
FUNC_ATTR_NONNULL_ARG(2, 3) FUNC_ATTR_NONNULL_ARG(2, 3)
@ -8165,7 +8167,7 @@ static void set_qf_ll_list(win_T *wp, typval_T *args, typval_T *rettv)
int action = ' '; int action = ' ';
static int recursive = 0; static int recursive = 0;
rettv->vval.v_number = -1; rettv->vval.v_number = -1;
dict_T *d = NULL; dict_T *what = NULL;
typval_T *list_arg = &args[0]; typval_T *list_arg = &args[0];
if (list_arg->v_type != VAR_LIST) { if (list_arg->v_type != VAR_LIST) {
@ -8193,18 +8195,18 @@ static void set_qf_ll_list(win_T *wp, typval_T *args, typval_T *rettv)
return; return;
} }
typval_T *title_arg = &args[2]; typval_T *const what_arg = &args[2];
if (title_arg->v_type == VAR_UNKNOWN) { if (what_arg->v_type == VAR_UNKNOWN) {
// Option argument was not given. // Option argument was not given.
goto skip_args; goto skip_args;
} else if (title_arg->v_type == VAR_STRING) { } else if (what_arg->v_type == VAR_STRING) {
title = tv_get_string_chk(title_arg); title = tv_get_string_chk(what_arg);
if (!title) { if (!title) {
// Type error. Error already printed by tv_get_string_chk(). // Type error. Error already printed by tv_get_string_chk().
return; return;
} }
} else if (title_arg->v_type == VAR_DICT) { } else if (what_arg->v_type == VAR_DICT && what_arg->vval.v_dict != NULL) {
d = title_arg->vval.v_dict; what = what_arg->vval.v_dict;
} else { } else {
EMSG(_(e_dictreq)); EMSG(_(e_dictreq));
return; return;
@ -8217,7 +8219,7 @@ skip_args:
recursive++; recursive++;
list_T *const l = list_arg->vval.v_list; list_T *const l = list_arg->vval.v_list;
if (set_errorlist(wp, l, action, (char_u *)title, d) == OK) { if (set_errorlist(wp, l, action, (char_u *)title, what) == OK) {
rettv->vval.v_number = 0; rettv->vval.v_number = 0;
} }
recursive--; recursive--;

View File

@ -1052,7 +1052,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars,
// A Lambda always has the command "return {expr}". It is much faster // A Lambda always has the command "return {expr}". It is much faster
// to evaluate {expr} directly. // to evaluate {expr} directly.
ex_nesting_level++; ex_nesting_level++;
eval1(&p, rettv, true); (void)eval1(&p, rettv, true);
ex_nesting_level--; ex_nesting_level--;
} else { } else {
// call do_cmdline() to execute the lines // call do_cmdline() to execute the lines

View File

@ -5400,7 +5400,7 @@ invalid_count:
if (parse_addr_type_arg(val, (int)vallen, argt, addr_type_arg) == FAIL) { if (parse_addr_type_arg(val, (int)vallen, argt, addr_type_arg) == FAIL) {
return FAIL; return FAIL;
} }
if (addr_type_arg != ADDR_LINES) { if (*addr_type_arg != ADDR_LINES) {
*argt |= (ZEROR | NOTADR); *argt |= (ZEROR | NOTADR);
} }
} else { } else {

View File

@ -5193,7 +5193,7 @@ ExpandFromContext (
* obtain strings, one by one. The strings are matched against a regexp * obtain strings, one by one. The strings are matched against a regexp
* program. Matching strings are copied into an array, which is returned. * program. Matching strings are copied into an array, which is returned.
*/ */
void ExpandGeneric( static void ExpandGeneric(
expand_T *xp, expand_T *xp,
regmatch_T *regmatch, regmatch_T *regmatch,
int *num_file, int *num_file,

View File

@ -6841,7 +6841,7 @@ static void nv_g_cmd(cmdarg_T *cap)
} else { } else {
if (cap->count1 > 1) { if (cap->count1 > 1) {
// if it fails, let the cursor still move to the last char // if it fails, let the cursor still move to the last char
cursor_down(cap->count1 - 1, false); (void)cursor_down(cap->count1 - 1, false);
} }
i = curwin->w_leftcol + curwin->w_width_inner - col_off - 1; i = curwin->w_leftcol + curwin->w_width_inner - col_off - 1;
coladvance((colnr_T)i); coladvance((colnr_T)i);

View File

@ -919,11 +919,11 @@ void pum_set_event_info(dict_T *dict)
r = (double)pum_row; r = (double)pum_row;
c = (double)pum_col; c = (double)pum_col;
} }
tv_dict_add_float(dict, S_LEN("height"), h); (void)tv_dict_add_float(dict, S_LEN("height"), h);
tv_dict_add_float(dict, S_LEN("width"), w); (void)tv_dict_add_float(dict, S_LEN("width"), w);
tv_dict_add_float(dict, S_LEN("row"), r); (void)tv_dict_add_float(dict, S_LEN("row"), r);
tv_dict_add_float(dict, S_LEN("col"), c); (void)tv_dict_add_float(dict, S_LEN("col"), c);
tv_dict_add_nr(dict, S_LEN("size"), pum_size); (void)tv_dict_add_nr(dict, S_LEN("size"), pum_size);
tv_dict_add_bool(dict, S_LEN("scrollbar"), (void)tv_dict_add_bool(dict, S_LEN("scrollbar"),
pum_scrollbar ? kBoolVarTrue : kBoolVarFalse); pum_scrollbar ? kBoolVarTrue : kBoolVarFalse);
} }

View File

@ -6317,6 +6317,7 @@ static void qf_free_stack(win_T *wp, qf_info_T *qi)
// Populate the quickfix list with the items supplied in the list // Populate the quickfix list with the items supplied in the list
// of dictionaries. "title" will be copied to w:quickfix_title // of dictionaries. "title" will be copied to w:quickfix_title
// "action" is 'a' for add, 'r' for replace. Otherwise create a new list. // "action" is 'a' for add, 'r' for replace. Otherwise create a new list.
// When "what" is not NULL then only set some properties.
int set_errorlist(win_T *wp, list_T *list, int action, char_u *title, int set_errorlist(win_T *wp, list_T *list, int action, char_u *title,
dict_T *what) dict_T *what)
{ {

View File

@ -327,7 +327,10 @@ func Test_compl_in_cmdwin()
set wildmenu wildchar=<Tab> set wildmenu wildchar=<Tab>
com! -nargs=1 -complete=command GetInput let input = <q-args> com! -nargs=1 -complete=command GetInput let input = <q-args>
com! -buffer TestCommand echo 'TestCommand' com! -buffer TestCommand echo 'TestCommand'
let w:test_winvar = 'winvar'
let b:test_bufvar = 'bufvar'
" User-defined commands
let input = '' let input = ''
call feedkeys("q:iGetInput T\<C-x>\<C-v>\<CR>", 'tx!') call feedkeys("q:iGetInput T\<C-x>\<C-v>\<CR>", 'tx!')
call assert_equal('TestCommand', input) call assert_equal('TestCommand', input)
@ -336,8 +339,29 @@ func Test_compl_in_cmdwin()
call feedkeys("q::GetInput T\<Tab>\<CR>:q\<CR>", 'tx!') call feedkeys("q::GetInput T\<Tab>\<CR>:q\<CR>", 'tx!')
call assert_equal('T', input) call assert_equal('T', input)
com! -nargs=1 -complete=var GetInput let input = <q-args>
" Window-local variables
let input = ''
call feedkeys("q:iGetInput w:test_\<C-x>\<C-v>\<CR>", 'tx!')
call assert_equal('w:test_winvar', input)
let input = ''
call feedkeys("q::GetInput w:test_\<Tab>\<CR>:q\<CR>", 'tx!')
call assert_equal('w:test_', input)
" Buffer-local variables
let input = ''
call feedkeys("q:iGetInput b:test_\<C-x>\<C-v>\<CR>", 'tx!')
call assert_equal('b:test_bufvar', input)
let input = ''
call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!')
call assert_equal('b:test_', input)
delcom TestCommand delcom TestCommand
delcom GetInput delcom GetInput
unlet w:test_winvar
unlet b:test_bufvar
set wildmenu& wildchar& set wildmenu& wildchar&
endfunc endfunc

View File

@ -74,6 +74,7 @@ func Test_echomsg()
call assert_equal("\n12345", execute(':echomsg 12345')) call assert_equal("\n12345", execute(':echomsg 12345'))
call assert_equal("\n[]", execute(':echomsg []')) call assert_equal("\n[]", execute(':echomsg []'))
call assert_equal("\n[1, 2, 3]", execute(':echomsg [1, 2, 3]')) call assert_equal("\n[1, 2, 3]", execute(':echomsg [1, 2, 3]'))
call assert_equal("\n[1, 2, []]", execute(':echomsg [1, 2, v:_null_list]'))
call assert_equal("\n{}", execute(':echomsg {}')) call assert_equal("\n{}", execute(':echomsg {}'))
call assert_equal("\n{'a': 1, 'b': 2}", execute(':echomsg {"a": 1, "b": 2}')) call assert_equal("\n{'a': 1, 'b': 2}", execute(':echomsg {"a": 1, "b": 2}'))
if has('float') if has('float')