To: vim_dev@googlegroups.com Subject: Patch 8.1.0560 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0560 Problem: Cannot use address type "other" with with user command. Solution: Add "other" to the list. (Daniel Hahler, closes #3655) Also reject "%" for commands with "other". Add some more tests. Files: src/ex_docmd.c, src/testdir/test_usercommands.vim *** ../vim-8.1.0559/src/ex_docmd.c 2018-10-19 22:35:04.885189994 +0200 --- src/ex_docmd.c 2018-12-02 17:58:11.339485922 +0100 *************** *** 2998,3003 **** --- 2998,3004 ---- } break; case ADDR_TABS_RELATIVE: + case ADDR_OTHER: *errormsg = (char_u *)_(e_invrange); return FAIL; case ADDR_ARGUMENTS: *************** *** 5940,5945 **** --- 5941,5947 ---- {ADDR_BUFFERS, "buffers"}, {ADDR_WINDOWS, "windows"}, {ADDR_QUICKFIX, "quickfix"}, + {ADDR_OTHER, "other"}, {-1, NULL} }; #endif *** ../vim-8.1.0559/src/testdir/test_usercommands.vim 2017-12-25 13:39:26.000000000 +0100 --- src/testdir/test_usercommands.vim 2018-12-02 18:17:46.460790379 +0100 *************** *** 154,160 **** call assert_equal('"com -nargs=* + 0 1 ?', @:) call feedkeys(":com -addr=\\\"\", 'tx') ! call assert_equal('"com -addr=arguments buffers lines loaded_buffers quickfix tabs windows', @:) call feedkeys(":com -complete=co\\\"\", 'tx') call assert_equal('"com -complete=color command compiler', @:) --- 154,160 ---- call assert_equal('"com -nargs=* + 0 1 ?', @:) call feedkeys(":com -addr=\\\"\", 'tx') ! call assert_equal('"com -addr=arguments buffers lines loaded_buffers other quickfix tabs windows', @:) call feedkeys(":com -complete=co\\\"\", 'tx') call assert_equal('"com -complete=color command compiler', @:) *************** *** 218,220 **** --- 218,278 ---- call assert_equal('"DoExec hi', @:) delcommand DoExec endfunc + + func Test_addr_all() + command! -addr=lines DoSomething let g:a1 = | let g:a2 = + %DoSomething + call assert_equal(1, g:a1) + call assert_equal(line('$'), g:a2) + + command! -addr=arguments DoSomething let g:a1 = | let g:a2 = + args one two three + %DoSomething + call assert_equal(1, g:a1) + call assert_equal(3, g:a2) + + command! -addr=buffers DoSomething let g:a1 = | let g:a2 = + %DoSomething + for low in range(1, bufnr('$')) + if buflisted(low) + break + endif + endfor + call assert_equal(low, g:a1) + call assert_equal(bufnr('$'), g:a2) + + command! -addr=loaded_buffers DoSomething let g:a1 = | let g:a2 = + %DoSomething + for low in range(1, bufnr('$')) + if bufloaded(low) + break + endif + endfor + call assert_equal(low, g:a1) + for up in range(bufnr('$'), 1, -1) + if bufloaded(up) + break + endif + endfor + call assert_equal(up, g:a2) + + command! -addr=windows DoSomething let g:a1 = | let g:a2 = + new + %DoSomething + call assert_equal(1, g:a1) + call assert_equal(winnr('$'), g:a2) + bwipe + + command! -addr=tabs DoSomething let g:a1 = | let g:a2 = + tabnew + %DoSomething + call assert_equal(1, g:a1) + call assert_equal(len(gettabinfo()), g:a2) + bwipe + + command! -addr=other DoSomething echo 'nothing' + DoSomething + call assert_fails('%DoSomething') + + delcommand DoSomething + endfunc *** ../vim-8.1.0559/src/version.c 2018-12-02 14:55:04.904731741 +0100 --- src/version.c 2018-12-02 18:05:03.897134687 +0100 *************** *** 794,795 **** --- 794,797 ---- { /* Add new patch number below this line */ + /**/ + 560, /**/ -- The Characters and incidents portrayed and the names used are fictitious and any similarity to the names, characters, or history of any person is entirely accidental and unintentional. Signed RICHARD M. NIXON "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///