mirror of
https://github.com/neovim/neovim.git
synced 2025-11-28 13:10:44 +00:00
Merge pull request #14131 from janlazo/vim-8.2.2596
vim-patch:8.2.{2596,2601,2604}
This commit is contained in:
@@ -968,7 +968,7 @@ static int do_autocmd_event(event_T event,
|
||||
// Implementation of ":doautocmd [group] event [fname]".
|
||||
// Return OK for success, FAIL for failure;
|
||||
int do_doautocmd(char_u *arg,
|
||||
int do_msg, // give message for no matching autocmds?
|
||||
bool do_msg, // give message for no matching autocmds?
|
||||
bool *did_something)
|
||||
{
|
||||
char_u *fname;
|
||||
@@ -1017,11 +1017,12 @@ int do_doautocmd(char_u *arg,
|
||||
// ":doautoall": execute autocommands for each loaded buffer.
|
||||
void ex_doautoall(exarg_T *eap)
|
||||
{
|
||||
int retval;
|
||||
int retval = OK;
|
||||
aco_save_T aco;
|
||||
char_u *arg = eap->arg;
|
||||
int call_do_modelines = check_nomodeline(&arg);
|
||||
bufref_T bufref;
|
||||
bool did_aucmd;
|
||||
|
||||
// This is a bit tricky: For some commands curwin->w_buffer needs to be
|
||||
// equal to curbuf, but for some buffers there may not be a window.
|
||||
@@ -1029,14 +1030,14 @@ void ex_doautoall(exarg_T *eap)
|
||||
// gives problems when the autocommands make changes to the list of
|
||||
// buffers or windows...
|
||||
FOR_ALL_BUFFERS(buf) {
|
||||
if (buf->b_ml.ml_mfp == NULL) {
|
||||
// Only do loaded buffers and skip the current buffer, it's done last.
|
||||
if (buf->b_ml.ml_mfp == NULL || buf == curbuf) {
|
||||
continue;
|
||||
}
|
||||
// Find a window for this buffer and save some values.
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
set_bufref(&bufref, buf);
|
||||
|
||||
bool did_aucmd;
|
||||
// execute the autocommands for this buffer
|
||||
retval = do_doautocmd(arg, false, &did_aucmd);
|
||||
|
||||
@@ -1052,10 +1053,19 @@ void ex_doautoall(exarg_T *eap)
|
||||
|
||||
// Stop if there is some error or buffer was deleted.
|
||||
if (retval == FAIL || !bufref_valid(&bufref)) {
|
||||
retval = FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Execute autocommands for the current buffer last.
|
||||
if (retval == OK) {
|
||||
(void)do_doautocmd(arg, false, &did_aucmd);
|
||||
if (call_do_modelines && did_aucmd) {
|
||||
do_modelines(0);
|
||||
}
|
||||
}
|
||||
|
||||
check_cursor(); // just in case lines got deleted
|
||||
}
|
||||
|
||||
@@ -1661,11 +1671,13 @@ static bool apply_autocmds_group(event_T event,
|
||||
did_filetype = false;
|
||||
while (au_pending_free_buf != NULL) {
|
||||
buf_T *b = au_pending_free_buf->b_next;
|
||||
|
||||
xfree(au_pending_free_buf);
|
||||
au_pending_free_buf = b;
|
||||
}
|
||||
while (au_pending_free_win != NULL) {
|
||||
win_T *w = au_pending_free_win->w_next;
|
||||
|
||||
xfree(au_pending_free_win);
|
||||
au_pending_free_win = w;
|
||||
}
|
||||
|
||||
@@ -1922,20 +1922,28 @@ func Test_autocmd_window()
|
||||
%bw!
|
||||
edit one.txt
|
||||
tabnew two.txt
|
||||
vnew three.txt
|
||||
tabnew four.txt
|
||||
tabprevious
|
||||
let g:blist = []
|
||||
augroup aucmd_win_test
|
||||
augroup aucmd_win_test1
|
||||
au!
|
||||
au BufEnter * call add(g:blist, [expand('<afile>'),
|
||||
\ win_gettype(bufwinnr(expand('<afile>')))])
|
||||
augroup END
|
||||
|
||||
doautoall BufEnter
|
||||
call assert_equal([['one.txt', 'autocmd'], ['two.txt', '']], g:blist)
|
||||
call assert_equal([
|
||||
\ ['one.txt', 'autocmd'],
|
||||
\ ['two.txt', ''],
|
||||
\ ['four.txt', 'autocmd'],
|
||||
\ ['three.txt', ''],
|
||||
\ ], g:blist)
|
||||
|
||||
augroup aucmd_win_test
|
||||
augroup aucmd_win_test1
|
||||
au!
|
||||
augroup END
|
||||
augroup! aucmd_win_test
|
||||
augroup! aucmd_win_test1
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
|
||||
@@ -111,10 +111,8 @@ func Test_pack_in_rtp_when_plugins_run()
|
||||
endfunc
|
||||
|
||||
func Test_help_arg()
|
||||
if !has('unix') && has('gui')
|
||||
" this doesn't work with gvim on MS-Windows
|
||||
return
|
||||
endif
|
||||
CheckNotMSWindows
|
||||
|
||||
if RunVim([], [], '--help >Xtestout')
|
||||
let lines = readfile('Xtestout')
|
||||
call assert_true(len(lines) > 20)
|
||||
@@ -412,6 +410,134 @@ func Test_A_F_H_arg()
|
||||
call delete('Xtestout')
|
||||
endfunc
|
||||
|
||||
" Test the --echo-wid argument (for GTK GUI only).
|
||||
func Test_echo_wid()
|
||||
CheckCanRunGui
|
||||
CheckFeature gui_gtk
|
||||
|
||||
if RunVim([], [], '-g --echo-wid -cq >Xtest_echo_wid')
|
||||
let lines = readfile('Xtest_echo_wid')
|
||||
call assert_equal(1, len(lines))
|
||||
call assert_match('^WID: \d\+$', lines[0])
|
||||
endif
|
||||
|
||||
call delete('Xtest_echo_wid')
|
||||
endfunction
|
||||
|
||||
" Test the -reverse and +reverse arguments (for GUI only).
|
||||
func Test_reverse()
|
||||
CheckCanRunGui
|
||||
CheckNotMSWindows
|
||||
|
||||
let after =<< trim [CODE]
|
||||
call writefile([&background], "Xtest_reverse")
|
||||
qall
|
||||
[CODE]
|
||||
if RunVim([], after, '-f -g -reverse')
|
||||
let lines = readfile('Xtest_reverse')
|
||||
call assert_equal(['dark'], lines)
|
||||
endif
|
||||
if RunVim([], after, '-f -g +reverse')
|
||||
let lines = readfile('Xtest_reverse')
|
||||
call assert_equal(['light'], lines)
|
||||
endif
|
||||
|
||||
call delete('Xtest_reverse')
|
||||
endfunc
|
||||
|
||||
" Test the -background and -foreground arguments (for GUI only).
|
||||
func Test_background_foreground()
|
||||
CheckCanRunGui
|
||||
CheckNotMSWindows
|
||||
|
||||
" Is there a better way to check the effect of -background & -foreground
|
||||
" other than merely looking at &background (dark or light)?
|
||||
let after =<< trim [CODE]
|
||||
call writefile([&background], "Xtest_fg_bg")
|
||||
qall
|
||||
[CODE]
|
||||
if RunVim([], after, '-f -g -background darkred -foreground yellow')
|
||||
let lines = readfile('Xtest_fg_bg')
|
||||
call assert_equal(['dark'], lines)
|
||||
endif
|
||||
if RunVim([], after, '-f -g -background ivory -foreground darkgreen')
|
||||
let lines = readfile('Xtest_fg_bg')
|
||||
call assert_equal(['light'], lines)
|
||||
endif
|
||||
|
||||
call delete('Xtest_fg_bg')
|
||||
endfunc
|
||||
|
||||
" Test the -font argument (for GUI only).
|
||||
func Test_font()
|
||||
CheckCanRunGui
|
||||
CheckNotMSWindows
|
||||
|
||||
if has('gui_gtk')
|
||||
let font = 'Courier 14'
|
||||
elseif has('gui_motif') || has('gui_athena')
|
||||
let font = '-misc-fixed-bold-*'
|
||||
else
|
||||
throw 'Skipped: test does not set a valid font for this GUI'
|
||||
endif
|
||||
|
||||
let after =<< trim [CODE]
|
||||
call writefile([&guifont], "Xtest_font")
|
||||
qall
|
||||
[CODE]
|
||||
|
||||
if RunVim([], after, '--nofork -g -font "' .. font .. '"')
|
||||
let lines = readfile('Xtest_font')
|
||||
call assert_equal([font], lines)
|
||||
endif
|
||||
|
||||
call delete('Xtest_font')
|
||||
endfunc
|
||||
|
||||
" Test the -geometry argument (for GUI only).
|
||||
func Test_geometry()
|
||||
CheckCanRunGui
|
||||
CheckNotMSWindows
|
||||
|
||||
if has('gui_motif') || has('gui_athena')
|
||||
" FIXME: With GUI Athena or Motif, the value of getwinposx(),
|
||||
" getwinposy() and getwinpos() do not match exactly the
|
||||
" value given in -geometry. Why?
|
||||
" So only check &columns and &lines for those GUIs.
|
||||
let after =<< trim [CODE]
|
||||
call writefile([&columns, &lines], "Xtest_geometry")
|
||||
qall
|
||||
[CODE]
|
||||
if RunVim([], after, '-f -g -geometry 31x13+41+43')
|
||||
let lines = readfile('Xtest_geometry')
|
||||
call assert_equal(['31', '13'], lines)
|
||||
endif
|
||||
else
|
||||
let after =<< trim [CODE]
|
||||
call writefile([&columns, &lines, getwinposx(), getwinposy(), string(getwinpos())], "Xtest_geometry")
|
||||
qall
|
||||
[CODE]
|
||||
if RunVim([], after, '-f -g -geometry 31x13+41+43')
|
||||
let lines = readfile('Xtest_geometry')
|
||||
call assert_equal(['31', '13', '41', '43', '[41, 43]'], lines)
|
||||
endif
|
||||
endif
|
||||
|
||||
call delete('Xtest_geometry')
|
||||
endfunc
|
||||
|
||||
" Test the -iconic argument (for GUI only).
|
||||
func Test_iconic()
|
||||
CheckCanRunGui
|
||||
CheckNotMSWindows
|
||||
|
||||
call RunVim([], [], '-f -g -iconic -cq')
|
||||
|
||||
" TODO: currently only start vim iconified, but does not
|
||||
" check that vim is iconified. How could this be checked?
|
||||
endfunc
|
||||
|
||||
|
||||
func Test_invalid_args()
|
||||
if !has('unix') || has('gui_running')
|
||||
" can't get output of Vim.
|
||||
@@ -777,17 +903,12 @@ func Test_progname()
|
||||
let prognames = ['nvim']
|
||||
|
||||
for progname in prognames
|
||||
if empty($DISPLAY)
|
||||
if progname =~# 'g'
|
||||
" Can't run gvim, gview (etc.) if $DISPLAY is not setup.
|
||||
continue
|
||||
endif
|
||||
if has('gui') && (progname ==# 'evim' || progname ==# 'eview')
|
||||
" evim or eview will start the GUI if there is gui support.
|
||||
" So don't try to start them either if $DISPLAY is not setup.
|
||||
continue
|
||||
endif
|
||||
endif
|
||||
let run_with_gui = (progname =~# 'g') || (has('gui') && (progname ==# 'evim' || progname ==# 'eview'))
|
||||
|
||||
if empty($DISPLAY) && run_with_gui
|
||||
" Can't run gvim, gview (etc.) if $DISPLAY is not setup.
|
||||
continue
|
||||
endif
|
||||
|
||||
exe 'silent !ln -s -f ' ..exepath(GetVimProg()) .. ' Xprogname/' .. progname
|
||||
|
||||
@@ -801,7 +922,15 @@ func Test_progname()
|
||||
if progname =~# 'g' && !has('gui')
|
||||
call assert_equal("E25: GUI cannot be used: Not enabled at compile time\n", stdout_stderr, progname)
|
||||
else
|
||||
call assert_equal('', stdout_stderr, progname)
|
||||
" GUI motif can output some warnings like this:
|
||||
" Warning:
|
||||
" Name: subMenu
|
||||
" Class: XmCascadeButton
|
||||
" Illegal mnemonic character; Could not convert X KEYSYM to a keycode
|
||||
" So don't check that stderr is empty with GUI Motif.
|
||||
if run_with_gui && !has('gui_motif')
|
||||
call assert_equal('', stdout_stderr, progname)
|
||||
endif
|
||||
call assert_equal(expectations[progname], readfile('Xprogname_out'), progname)
|
||||
endif
|
||||
|
||||
|
||||
@@ -157,8 +157,8 @@ describe('memory usage', function()
|
||||
-- The usage may be a bit less than the last value, use 80%.
|
||||
-- Allow for 20% tolerance at the upper limit. That's very permissive, but
|
||||
-- otherwise the test fails sometimes. On Sourcehut CI with FreeBSD we need to
|
||||
-- be even more permissive.
|
||||
local upper_multiplier = uname() == 'freebsd' and 15 or 12
|
||||
-- be even much more permissive.
|
||||
local upper_multiplier = uname() == 'freebsd' and 19 or 12
|
||||
local lower = before.last * 8 / 10
|
||||
local upper = load_adjust((after.max + (after.last - before.last)) * upper_multiplier / 10)
|
||||
check_result({before=before, after=after, last=last},
|
||||
|
||||
Reference in New Issue
Block a user