Compare commits

...

2 Commits

Author SHA1 Message Date
Bram Moolenaar
3e93a2b075 patch 8.2.4209: partial in 'opfunc' cannot use an imported function
Problem:    partial in 'opfunc' cannot use an imported function.
Solution:   Also expand the function name in a partial. (closes #9614)
2022-01-24 21:28:01 +00:00
Bram Moolenaar
dff97e65eb patch 8.2.4208: using setbufvar() may change the window title
Problem:    Using setbufvar() may change the window title.
Solution:   Do not redraw when creating the autocommand window. (closes #9613)
2022-01-24 20:00:55 +00:00
5 changed files with 86 additions and 8 deletions

View File

@@ -1518,7 +1518,10 @@ aucmd_prepbuf(
p_acd = FALSE;
#endif
// no redrawing and don't set the window title
++RedrawingDisabled;
(void)win_split_ins(0, WSP_TOP, aucmd_win, 0);
--RedrawingDisabled;
(void)win_comp_pos(); // recompute window positions
p_ea = save_ea;
#ifdef FEAT_AUTOCHDIR

View File

@@ -4680,27 +4680,44 @@ copy_callback(callback_T *dest, callback_T *src)
void
expand_autload_callback(callback_T *cb)
{
char_u *name;
char_u *p;
imported_T *import;
if (!in_vim9script() || cb->cb_name == NULL || !cb->cb_free_name)
if (!in_vim9script() || cb->cb_name == NULL
|| (!cb->cb_free_name
&& (cb->cb_partial == NULL || cb->cb_partial->pt_name == NULL)))
return;
p = vim_strchr(cb->cb_name, '.');
if (cb->cb_partial != NULL)
name = cb->cb_partial->pt_name;
else
name = cb->cb_name;
p = vim_strchr(name, '.');
if (p == NULL)
return;
import = find_imported(cb->cb_name, p - cb->cb_name, FALSE, NULL);
import = find_imported(name, p - name, FALSE, NULL);
if (import != NULL && SCRIPT_ID_VALID(import->imp_sid))
{
scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
if (si->sn_autoload_prefix != NULL)
{
char_u *name = concat_str(si->sn_autoload_prefix, p + 1);
char_u *newname = concat_str(si->sn_autoload_prefix, p + 1);
if (name != NULL)
if (newname != NULL)
{
vim_free(cb->cb_name);
cb->cb_name = name;
if (cb->cb_partial != NULL)
{
if (cb->cb_name == cb->cb_partial->pt_name)
cb->cb_name = newname;
vim_free(cb->cb_partial->pt_name);
cb->cb_partial->pt_name = newname;
}
else
{
vim_free(cb->cb_name);
cb->cb_name = newname;
}
}
}
}

View File

@@ -1630,6 +1630,28 @@ func Test_setbufvar_options()
bwipe!
endfunc
func Test_setbufvar_keep_window_title()
CheckRunVimInTerminal
let lines =<< trim END
edit Xa.txt
let g:buf = bufadd('Xb.txt')
inoremap <F2> <C-R>=setbufvar(g:buf, '&autoindent', 1) ?? ''<CR>
END
call writefile(lines, 'Xsetbufvar')
let buf = RunVimInTerminal('-S Xsetbufvar', {})
call assert_match('Xa.txt', term_gettitle(buf))
call term_sendkeys(buf, "i\<F2>")
call TermWait(buf)
call term_sendkeys(buf, "\<Esc>")
call TermWait(buf)
call assert_match('Xa.txt', term_gettitle(buf))
call StopVimInTerminal(buf)
call delete('Xsetbufvar')
endfunc
func Test_redo_in_nested_functions()
nnoremap g. :set opfunc=Operator<CR>g@
function Operator( type, ... )
@@ -2308,7 +2330,6 @@ endfunc
func Test_state()
CheckRunVimInTerminal
let g:test_is_flaky = 1
let getstate = ":echo 'state: ' .. g:state .. '; mode: ' .. g:mode\<CR>"

View File

@@ -673,6 +673,39 @@ def Test_use_autoload_import_in_insert_completion()
&rtp = save_rtp
enddef
def Test_use_autoload_import_partial_in_opfunc()
mkdir('Xdir/autoload', 'p')
var save_rtp = &rtp
exe 'set rtp^=' .. getcwd() .. '/Xdir'
var lines =<< trim END
vim9script
export def Opfunc(..._)
g:opfunc_called = 'yes'
enddef
END
writefile(lines, 'Xdir/autoload/opfunc.vim')
new
lines =<< trim END
vim9script
import autoload 'opfunc.vim'
nnoremap <expr> <F3> TheFunc()
def TheFunc(): string
&operatorfunc = function('opfunc.Opfunc', [0])
return 'g@'
enddef
feedkeys("\<F3>l", 'xt')
assert_equal('yes', g:opfunc_called)
END
CheckScriptSuccess(lines)
set opfunc=
bwipe!
delete('Xdir', 'rf')
&rtp = save_rtp
enddef
def Test_use_autoload_import_in_fold_expression()
mkdir('Xdir/autoload', 'p')
var save_rtp = &rtp

View File

@@ -750,6 +750,10 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4209,
/**/
4208,
/**/
4207,
/**/