mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.0560: cannot use address type "other" with with user command
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.
This commit is contained in:
parent
b513d3079b
commit
51a7454cd2
@ -2998,6 +2998,7 @@ parse_cmd_address(exarg_T *eap, char_u **errormsg, int silent)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ADDR_TABS_RELATIVE:
|
case ADDR_TABS_RELATIVE:
|
||||||
|
case ADDR_OTHER:
|
||||||
*errormsg = (char_u *)_(e_invrange);
|
*errormsg = (char_u *)_(e_invrange);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
case ADDR_ARGUMENTS:
|
case ADDR_ARGUMENTS:
|
||||||
@ -5940,6 +5941,7 @@ static struct
|
|||||||
{ADDR_BUFFERS, "buffers"},
|
{ADDR_BUFFERS, "buffers"},
|
||||||
{ADDR_WINDOWS, "windows"},
|
{ADDR_WINDOWS, "windows"},
|
||||||
{ADDR_QUICKFIX, "quickfix"},
|
{ADDR_QUICKFIX, "quickfix"},
|
||||||
|
{ADDR_OTHER, "other"},
|
||||||
{-1, NULL}
|
{-1, NULL}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -154,7 +154,7 @@ func Test_CmdCompletion()
|
|||||||
call assert_equal('"com -nargs=* + 0 1 ?', @:)
|
call assert_equal('"com -nargs=* + 0 1 ?', @:)
|
||||||
|
|
||||||
call feedkeys(":com -addr=\<C-A>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":com -addr=\<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_equal('"com -addr=arguments buffers lines loaded_buffers quickfix tabs windows', @:)
|
call assert_equal('"com -addr=arguments buffers lines loaded_buffers other quickfix tabs windows', @:)
|
||||||
|
|
||||||
call feedkeys(":com -complete=co\<C-A>\<C-B>\"\<CR>", 'tx')
|
call feedkeys(":com -complete=co\<C-A>\<C-B>\"\<CR>", 'tx')
|
||||||
call assert_equal('"com -complete=color command compiler', @:)
|
call assert_equal('"com -complete=color command compiler', @:)
|
||||||
@ -218,3 +218,61 @@ func Test_use_execute_in_completion()
|
|||||||
call assert_equal('"DoExec hi', @:)
|
call assert_equal('"DoExec hi', @:)
|
||||||
delcommand DoExec
|
delcommand DoExec
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_addr_all()
|
||||||
|
command! -addr=lines DoSomething let g:a1 = <line1> | let g:a2 = <line2>
|
||||||
|
%DoSomething
|
||||||
|
call assert_equal(1, g:a1)
|
||||||
|
call assert_equal(line('$'), g:a2)
|
||||||
|
|
||||||
|
command! -addr=arguments DoSomething let g:a1 = <line1> | let g:a2 = <line2>
|
||||||
|
args one two three
|
||||||
|
%DoSomething
|
||||||
|
call assert_equal(1, g:a1)
|
||||||
|
call assert_equal(3, g:a2)
|
||||||
|
|
||||||
|
command! -addr=buffers DoSomething let g:a1 = <line1> | let g:a2 = <line2>
|
||||||
|
%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 = <line1> | let g:a2 = <line2>
|
||||||
|
%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 = <line1> | let g:a2 = <line2>
|
||||||
|
new
|
||||||
|
%DoSomething
|
||||||
|
call assert_equal(1, g:a1)
|
||||||
|
call assert_equal(winnr('$'), g:a2)
|
||||||
|
bwipe
|
||||||
|
|
||||||
|
command! -addr=tabs DoSomething let g:a1 = <line1> | let g:a2 = <line2>
|
||||||
|
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
|
||||||
|
@ -792,6 +792,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 */
|
||||||
|
/**/
|
||||||
|
560,
|
||||||
/**/
|
/**/
|
||||||
559,
|
559,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user