mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
vim-patch:9.0.0990: callback name argument is changed by setqflist()
Problem: Callback name argument is changed by setqflist().
Solution: Use the expanded function name for the callback, do not store it
in the argument. (closes vim/vim#11653)
c96b7f5d2a
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -5510,6 +5510,7 @@ void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, bool retlist
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a callback from "arg". It can be a Funcref or a function name.
|
||||
bool callback_from_typval(Callback *const callback, typval_T *const arg)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
@@ -5531,16 +5532,14 @@ bool callback_from_typval(Callback *const callback, typval_T *const arg)
|
||||
callback->type = kCallbackNone;
|
||||
callback->data.funcref = NULL;
|
||||
} else {
|
||||
callback->data.funcref = NULL;
|
||||
if (arg->v_type == VAR_STRING) {
|
||||
char *newname = get_scriptlocal_funcname(arg->vval.v_string);
|
||||
if (newname != NULL) {
|
||||
xfree(arg->vval.v_string);
|
||||
name = arg->vval.v_string = newname;
|
||||
}
|
||||
callback->data.funcref = get_scriptlocal_funcname(name);
|
||||
}
|
||||
|
||||
func_ref((char_u *)name);
|
||||
callback->data.funcref = xstrdup(name);
|
||||
if (callback->data.funcref == NULL) {
|
||||
callback->data.funcref = xstrdup(name);
|
||||
}
|
||||
func_ref((char_u *)callback->data.funcref);
|
||||
callback->type = kCallbackFuncref;
|
||||
}
|
||||
} else if (nlua_is_table_from_lua(arg)) {
|
||||
|
@@ -6180,5 +6180,17 @@ func Test_loclist_replace_autocmd()
|
||||
call setloclist(0, [], 'f')
|
||||
endfunc
|
||||
|
||||
func s:QfTf(_)
|
||||
endfunc
|
||||
|
||||
func Test_setqflist_cb_arg()
|
||||
" This was changing the callback name in the dictionary.
|
||||
let d = #{quickfixtextfunc: 's:QfTf'}
|
||||
call setqflist([], 'a', d)
|
||||
call assert_equal('s:QfTf', d.quickfixtextfunc)
|
||||
|
||||
call setqflist([], 'f')
|
||||
endfunc
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user