mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.1.0835: :setglobal doesn't work properly for 'ffu' and 'tsrfu'
Problem: :setglobal doesn't work properly for 'ffu' and 'tsrfu' when the local value is set (after v9.1.0831) Solution: Check os_flags instead of buffer option variable (zeertzjq). closes: #15980 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
ca6231b8a6
commit
6eda269600
@ -6934,6 +6934,9 @@ get_findfunc_callback(void)
|
|||||||
return *curbuf->b_p_ffu != NUL ? &curbuf->b_ffu_cb : &ffu_cb;
|
return *curbuf->b_p_ffu != NUL ? &curbuf->b_ffu_cb : &ffu_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call 'findfunc' to obtain a list of file names.
|
||||||
|
*/
|
||||||
static list_T *
|
static list_T *
|
||||||
call_findfunc(char_u *pat, int cmdcomplete)
|
call_findfunc(char_u *pat, int cmdcomplete)
|
||||||
{
|
{
|
||||||
@ -6944,7 +6947,6 @@ call_findfunc(char_u *pat, int cmdcomplete)
|
|||||||
sctx_T saved_sctx = current_sctx;
|
sctx_T saved_sctx = current_sctx;
|
||||||
sctx_T *ctx;
|
sctx_T *ctx;
|
||||||
|
|
||||||
// Call 'findfunc' to obtain the list of file names.
|
|
||||||
args[0].v_type = VAR_STRING;
|
args[0].v_type = VAR_STRING;
|
||||||
args[0].vval.v_string = pat;
|
args[0].vval.v_string = pat;
|
||||||
args[1].v_type = VAR_BOOL;
|
args[1].v_type = VAR_BOOL;
|
||||||
@ -7076,15 +7078,16 @@ did_set_findfunc(optset_T *args UNUSED)
|
|||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (*curbuf->b_p_ffu != NUL)
|
if (args->os_flags & OPT_LOCAL)
|
||||||
{
|
|
||||||
// buffer-local option set
|
// buffer-local option set
|
||||||
retval = option_set_callback_func(curbuf->b_p_ffu, &curbuf->b_ffu_cb);
|
retval = option_set_callback_func(curbuf->b_p_ffu, &curbuf->b_ffu_cb);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// global option set
|
// global option set
|
||||||
retval = option_set_callback_func(p_ffu, &ffu_cb);
|
retval = option_set_callback_func(p_ffu, &ffu_cb);
|
||||||
|
// when using :set, free the local callback
|
||||||
|
if (!(args->os_flags & OPT_GLOBAL))
|
||||||
|
free_callback(&curbuf->b_ffu_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval == FAIL)
|
if (retval == FAIL)
|
||||||
|
@ -2687,16 +2687,17 @@ did_set_thesaurusfunc(optset_T *args UNUSED)
|
|||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (*curbuf->b_p_tsrfu != NUL)
|
if (args->os_flags & OPT_LOCAL)
|
||||||
{
|
|
||||||
// buffer-local option set
|
// buffer-local option set
|
||||||
retval = option_set_callback_func(curbuf->b_p_tsrfu,
|
retval = option_set_callback_func(curbuf->b_p_tsrfu,
|
||||||
&curbuf->b_tsrfu_cb);
|
&curbuf->b_tsrfu_cb);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// global option set
|
// global option set
|
||||||
retval = option_set_callback_func(p_tsrfu, &tsrfu_cb);
|
retval = option_set_callback_func(p_tsrfu, &tsrfu_cb);
|
||||||
|
// when using :set, free the local callback
|
||||||
|
if (!(args->os_flags & OPT_GLOBAL))
|
||||||
|
free_callback(&curbuf->b_tsrfu_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval == FAIL ? e_invalid_argument : NULL;
|
return retval == FAIL ? e_invalid_argument : NULL;
|
||||||
|
@ -359,7 +359,7 @@ func Test_findfunc()
|
|||||||
|
|
||||||
" Error cases
|
" Error cases
|
||||||
|
|
||||||
" Function that doesn't any argument
|
" Function that doesn't take any arguments
|
||||||
func FindFuncNoArg()
|
func FindFuncNoArg()
|
||||||
endfunc
|
endfunc
|
||||||
set findfunc=FindFuncNoArg
|
set findfunc=FindFuncNoArg
|
||||||
@ -479,6 +479,41 @@ func Test_findfunc_scriptlocal_func()
|
|||||||
call assert_equal('abc', g:FindFuncArg)
|
call assert_equal('abc', g:FindFuncArg)
|
||||||
bw!
|
bw!
|
||||||
|
|
||||||
|
new | only
|
||||||
|
set findfunc=
|
||||||
|
setlocal findfunc=NoSuchFunc
|
||||||
|
setglobal findfunc=s:FindFuncScript
|
||||||
|
call assert_equal('NoSuchFunc', &findfunc)
|
||||||
|
call assert_equal('NoSuchFunc', &l:findfunc)
|
||||||
|
call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
|
||||||
|
new | only
|
||||||
|
call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
|
||||||
|
call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
|
||||||
|
call assert_equal('', &l:findfunc)
|
||||||
|
let g:FindFuncArg = ''
|
||||||
|
find abc
|
||||||
|
call assert_equal('abc', g:FindFuncArg)
|
||||||
|
bw!
|
||||||
|
|
||||||
|
new | only
|
||||||
|
set findfunc=
|
||||||
|
setlocal findfunc=NoSuchFunc
|
||||||
|
set findfunc=s:FindFuncScript
|
||||||
|
call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
|
||||||
|
call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
|
||||||
|
call assert_equal('', &l:findfunc)
|
||||||
|
let g:FindFuncArg = ''
|
||||||
|
find abc
|
||||||
|
call assert_equal('abc', g:FindFuncArg)
|
||||||
|
new | only
|
||||||
|
call assert_equal(expand('<SID>') .. 'FindFuncScript', &findfunc)
|
||||||
|
call assert_equal(expand('<SID>') .. 'FindFuncScript', &g:findfunc)
|
||||||
|
call assert_equal('', &l:findfunc)
|
||||||
|
let g:FindFuncArg = ''
|
||||||
|
find abc
|
||||||
|
call assert_equal('abc', g:FindFuncArg)
|
||||||
|
bw!
|
||||||
|
|
||||||
set findfunc=
|
set findfunc=
|
||||||
delfunc s:FindFuncScript
|
delfunc s:FindFuncScript
|
||||||
endfunc
|
endfunc
|
||||||
|
@ -2190,6 +2190,7 @@ func Test_thesaurusfunc_callback()
|
|||||||
call add(g:TsrFunc3Args, [a:findstart, a:base])
|
call add(g:TsrFunc3Args, [a:findstart, a:base])
|
||||||
return a:findstart ? 0 : []
|
return a:findstart ? 0 : []
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
set tsrfu=s:TsrFunc3
|
set tsrfu=s:TsrFunc3
|
||||||
new
|
new
|
||||||
call setline(1, 'script1')
|
call setline(1, 'script1')
|
||||||
@ -2205,6 +2206,46 @@ func Test_thesaurusfunc_callback()
|
|||||||
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
|
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
|
||||||
call assert_equal([[1, ''], [0, 'script2']], g:TsrFunc3Args)
|
call assert_equal([[1, ''], [0, 'script2']], g:TsrFunc3Args)
|
||||||
bw!
|
bw!
|
||||||
|
|
||||||
|
new | only
|
||||||
|
set thesaurusfunc=
|
||||||
|
setlocal thesaurusfunc=NoSuchFunc
|
||||||
|
setglobal thesaurusfunc=s:TsrFunc3
|
||||||
|
call assert_equal('NoSuchFunc', &thesaurusfunc)
|
||||||
|
call assert_equal('NoSuchFunc', &l:thesaurusfunc)
|
||||||
|
call assert_equal('s:TsrFunc3', &g:thesaurusfunc)
|
||||||
|
new | only
|
||||||
|
call assert_equal('s:TsrFunc3', &thesaurusfunc)
|
||||||
|
call assert_equal('s:TsrFunc3', &g:thesaurusfunc)
|
||||||
|
call assert_equal('', &l:thesaurusfunc)
|
||||||
|
call setline(1, 'script1')
|
||||||
|
let g:TsrFunc3Args = []
|
||||||
|
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
|
||||||
|
call assert_equal([[1, ''], [0, 'script1']], g:TsrFunc3Args)
|
||||||
|
bw!
|
||||||
|
|
||||||
|
new | only
|
||||||
|
set thesaurusfunc=
|
||||||
|
setlocal thesaurusfunc=NoSuchFunc
|
||||||
|
set thesaurusfunc=s:TsrFunc3
|
||||||
|
call assert_equal('s:TsrFunc3', &thesaurusfunc)
|
||||||
|
call assert_equal('s:TsrFunc3', &g:thesaurusfunc)
|
||||||
|
call assert_equal('', &l:thesaurusfunc)
|
||||||
|
call setline(1, 'script1')
|
||||||
|
let g:TsrFunc3Args = []
|
||||||
|
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
|
||||||
|
call assert_equal([[1, ''], [0, 'script1']], g:TsrFunc3Args)
|
||||||
|
setlocal bufhidden=wipe
|
||||||
|
new | only!
|
||||||
|
call assert_equal('s:TsrFunc3', &thesaurusfunc)
|
||||||
|
call assert_equal('s:TsrFunc3', &g:thesaurusfunc)
|
||||||
|
call assert_equal('', &l:thesaurusfunc)
|
||||||
|
call setline(1, 'script1')
|
||||||
|
let g:TsrFunc3Args = []
|
||||||
|
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
|
||||||
|
call assert_equal([[1, ''], [0, 'script1']], g:TsrFunc3Args)
|
||||||
|
bw!
|
||||||
|
|
||||||
delfunc s:TsrFunc3
|
delfunc s:TsrFunc3
|
||||||
|
|
||||||
" invalid return value
|
" invalid return value
|
||||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
835,
|
||||||
/**/
|
/**/
|
||||||
834,
|
834,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user