vim-patch:9.1.0156: Make 'wfb' failing to split still report E1513

Problem:  may not be clear why failing to split causes an ":Xdo" command
          to abort if 'wfb' is set.
Solution: do not return immediately if win_split fails, so E1513 is
          still given. Expect both errors in the test. Also fix tests to
          pass CI.
          (Sean Dewar)

closes: vim/vim#14152

769eb2d0c3

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
This commit is contained in:
zeertzjq
2024-03-11 11:26:02 +08:00
parent d71791a11a
commit 3b3511c4d9
3 changed files with 46 additions and 22 deletions

View File

@@ -457,12 +457,11 @@ void ex_listdo(exarg_T *eap)
} }
if (curwin->w_p_wfb) { if (curwin->w_p_wfb) {
// Split the window, which will be 'nowinfixbuf', and set curwin to that // Split the window, which will be 'nowinfixbuf', and set curwin to that
if (win_split(0, 0) == FAIL) { (void)win_split(0, 0);
return; // error message already given
}
if (curwin->w_p_wfb) { if (curwin->w_p_wfb) {
// Autocommands set 'winfixbuf' or sent us to another window // Autocommands set 'winfixbuf' or sent us to another window
// with it set. Give up. // with it set, or we failed to split the window. Give up.
emsg(_(e_winfixbuf_cannot_go_to_buffer)); emsg(_(e_winfixbuf_cannot_go_to_buffer));
return; return;
} }

View File

@@ -2828,8 +2828,9 @@ static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit, int
} }
if (curwin->w_p_wfb) { if (curwin->w_p_wfb) {
// Autocommands set 'winfixbuf' or sent us to another window // Autocommands set 'winfixbuf' or sent us to another window
// with it set. Give up, but don't return immediately, as // with it set, or we failed to split the window. Give up,
// they may have messed with the list. // but don't return immediately, as they may have messed
// with the list.
emsg(_(e_winfixbuf_cannot_go_to_buffer)); emsg(_(e_winfixbuf_cannot_go_to_buffer));
retval = FAIL; retval = FAIL;
} }

View File

@@ -479,6 +479,9 @@ endfunc
" Fail :browse edit but :browse edit! is allowed " Fail :browse edit but :browse edit! is allowed
func Test_browse_edit_fail() func Test_browse_edit_fail()
" A GUI dialog may stall the test.
CheckNotGui
call s:reset_all_buffers() call s:reset_all_buffers()
let l:other = s:make_buffer_pairs() let l:other = s:make_buffer_pairs()
@@ -487,18 +490,31 @@ func Test_browse_edit_fail()
call assert_fails("browse edit other", "E1513:") call assert_fails("browse edit other", "E1513:")
call assert_equal(l:current, bufnr()) call assert_equal(l:current, bufnr())
try
browse edit! other browse edit! other
call assert_equal(l:other, bufnr()) call assert_equal(l:other, bufnr())
catch /E338:/
" Ignore E338, which occurs if console Vim is built with +browse.
" Console Vim without +browse will treat this as a regular :edit.
endtry
endfunc endfunc
" Allow :browse w because it doesn't change the buffer in the current file " Allow :browse w because it doesn't change the buffer in the current file
func Test_browse_edit_pass() func Test_browse_edit_pass()
" A GUI dialog may stall the test.
CheckNotGui
call s:reset_all_buffers() call s:reset_all_buffers()
let l:other = s:make_buffer_pairs() let l:other = s:make_buffer_pairs()
let l:current = bufnr() let l:current = bufnr()
try
browse write other browse write other
catch /E338:/
" Ignore E338, which occurs if console Vim is built with +browse.
" Console Vim without +browse will treat this as a regular :write.
endtry
call delete("other") call delete("other")
endfunc endfunc
@@ -1145,6 +1161,7 @@ func Test_find()
let l:current = bufnr() let l:current = bufnr()
let l:file = tempname() let l:file = tempname()
call writefile([], l:file) call writefile([], l:file)
let l:file = fnamemodify(l:file, ':p') " In case it's Windows 8.3-style.
let l:directory = fnamemodify(l:file, ":p:h") let l:directory = fnamemodify(l:file, ":p:h")
let l:name = fnamemodify(l:file, ":p:t") let l:name = fnamemodify(l:file, ":p:t")
@@ -1514,6 +1531,7 @@ func Test_lnfile()
call assert_equal(l:current, bufnr()) call assert_equal(l:current, bufnr())
call assert_fails("lnfile", "E1513:") call assert_fails("lnfile", "E1513:")
" Ensure the entry didn't change.
call assert_equal(2, getloclist(0, #{idx: 0}).idx) call assert_equal(2, getloclist(0, #{idx: 0}).idx)
call assert_equal(l:current, bufnr()) call assert_equal(l:current, bufnr())
@@ -2490,8 +2508,8 @@ func Test_previous()
call assert_equal(l:first, bufnr()) call assert_equal(l:first, bufnr())
endfunc endfunc
" Fail pydo if it changes a window with 'winfixbuf' is set " Fail pyxdo if it changes a window with 'winfixbuf' is set
func Test_python_pydo() func Test_pythonx_pyxdo()
CheckFeature pythonx CheckFeature pythonx
call s:reset_all_buffers() call s:reset_all_buffers()
@@ -2504,16 +2522,16 @@ func Test_python_pydo()
set winfixbuf set winfixbuf
python << EOF pythonx << EOF
import vim import vim
def test_winfixbuf_Test_python_pydo_set_buffer(): def test_winfixbuf_Test_pythonx_pyxdo_set_buffer():
buffer = vim.vars['_previous_buffer'] buffer = vim.vars['_previous_buffer']
vim.current.buffer = vim.buffers[buffer] vim.current.buffer = vim.buffers[buffer]
EOF EOF
try try
pydo test_winfixbuf_Test_python_pydo_set_buffer() pyxdo test_winfixbuf_Test_pythonx_pyxdo_set_buffer()
catch /pynvim\.api\.common\.NvimError: E1513: Cannot edit buffer\. 'winfixbuf' is enabled/ catch /pynvim\.api\.common\.NvimError: E1513: Cannot edit buffer\. 'winfixbuf' is enabled/
let l:caught = 1 let l:caught = 1
endtry endtry
@@ -2523,8 +2541,8 @@ EOF
unlet g:_previous_buffer unlet g:_previous_buffer
endfunc endfunc
" Fail pyfile if it changes a window with 'winfixbuf' is set " Fail pyxfile if it changes a window with 'winfixbuf' is set
func Test_python_pyfile() func Test_pythonx_pyxfile()
CheckFeature pythonx CheckFeature pythonx
call s:reset_all_buffers() call s:reset_all_buffers()
@@ -2544,7 +2562,7 @@ func Test_python_pyfile()
\ "file.py") \ "file.py")
try try
pyfile file.py pyxfile file.py
catch /pynvim\.api\.common\.NvimError: E1513: Cannot edit buffer\. 'winfixbuf' is enabled/ catch /pynvim\.api\.common\.NvimError: E1513: Cannot edit buffer\. 'winfixbuf' is enabled/
let l:caught = 1 let l:caught = 1
endtry endtry
@@ -2556,7 +2574,7 @@ func Test_python_pyfile()
endfunc endfunc
" Fail vim.current.buffer if 'winfixbuf' is set " Fail vim.current.buffer if 'winfixbuf' is set
func Test_python_vim_current_buffer() func Test_pythonx_vim_current_buffer()
CheckFeature pythonx CheckFeature pythonx
call s:reset_all_buffers() call s:reset_all_buffers()
@@ -2572,7 +2590,7 @@ func Test_python_vim_current_buffer()
set winfixbuf set winfixbuf
try try
python << EOF pythonx << EOF
import vim import vim
buffer = vim.vars["_previous_buffer"] buffer = vim.vars["_previous_buffer"]
@@ -3248,14 +3266,20 @@ func Test_quickfix_changed_split_failed()
augroup! QfChanged augroup! QfChanged
endfunc endfunc
func Test_bufdo_splitwin_fails() func Test_bufdo_cnext_splitwin_fails()
call s:reset_all_buffers() call s:reset_all_buffers()
let other = s:make_buffer_pairs() call s:make_simple_quickfix()
call assert_equal(1, getqflist(#{idx: 0}).idx)
" Make sure there is not enough room to " Make sure there is not enough room to
" split the winfixedbuf window " split the winfixedbuf window
let &winheight=&lines let &winheight=&lines
let &winminheight=&lines-2 let &winminheight=&lines-2
call assert_fails(':bufdo echo 1', 'E36:') " Still want E1513, or it may not be clear why a split was attempted and why
" it failing caused the commands to abort.
call assert_fails(':bufdo echo 1', ['E36:', 'E1513:'])
call assert_fails(':cnext', ['E36:', 'E1513:'])
" Ensure the entry didn't change.
call assert_equal(1, getqflist(#{idx: 0}).idx)
set winminheight&vim winheight&vim set winminheight&vim winheight&vim
endfunc endfunc