mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
vim-patch:8.2.1472: ":argdel" does not work like ":.argdel" as documented
Problem: ":argdel" does not work like ":.argdel" as documented. (Alexey
Demin)
Solution: Make ":argdel" work like ":.argdel". (closes vim/vim#6727)
Also fix giving the error "0 more files to edit".
7b22117c4e
This commit is contained in:
@@ -1984,9 +1984,16 @@ void ex_argadd(exarg_T *eap)
|
|||||||
/// ":argdelete"
|
/// ":argdelete"
|
||||||
void ex_argdelete(exarg_T *eap)
|
void ex_argdelete(exarg_T *eap)
|
||||||
{
|
{
|
||||||
if (eap->addr_count > 0) {
|
if (eap->addr_count > 0 || *eap->arg == NUL) {
|
||||||
|
// ":argdel" works like ":.argdel"
|
||||||
|
if (eap->addr_count == 0) {
|
||||||
|
if (curwin->w_arg_idx >= ARGCOUNT) {
|
||||||
|
EMSG(_("E610: No argument to delete"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
eap->line1 = eap->line2 = curwin->w_arg_idx + 1;
|
||||||
|
} else if (eap->line2 > ARGCOUNT) {
|
||||||
// ":1,4argdel": Delete all arguments in the range.
|
// ":1,4argdel": Delete all arguments in the range.
|
||||||
if (eap->line2 > ARGCOUNT) {
|
|
||||||
eap->line2 = ARGCOUNT;
|
eap->line2 = ARGCOUNT;
|
||||||
}
|
}
|
||||||
linenr_T n = eap->line2 - eap->line1 + 1;
|
linenr_T n = eap->line2 - eap->line1 + 1;
|
||||||
@@ -2016,8 +2023,6 @@ void ex_argdelete(exarg_T *eap)
|
|||||||
curwin->w_arg_idx = ARGCOUNT - 1;
|
curwin->w_arg_idx = ARGCOUNT - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (*eap->arg == NUL) {
|
|
||||||
EMSG(_(e_argreq));
|
|
||||||
} else {
|
} else {
|
||||||
do_arglist(eap->arg, AL_DEL, 0);
|
do_arglist(eap->arg, AL_DEL, 0);
|
||||||
}
|
}
|
||||||
|
@@ -4949,7 +4949,7 @@ check_more(
|
|||||||
int n = ARGCOUNT - curwin->w_arg_idx - 1;
|
int n = ARGCOUNT - curwin->w_arg_idx - 1;
|
||||||
|
|
||||||
if (!forceit && only_one_window()
|
if (!forceit && only_one_window()
|
||||||
&& ARGCOUNT > 1 && !arg_had_last && n >= 0 && quitmore == 0) {
|
&& ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0) {
|
||||||
if (message) {
|
if (message) {
|
||||||
if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) {
|
if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) {
|
||||||
char_u buff[DIALOG_MSG_SIZE];
|
char_u buff[DIALOG_MSG_SIZE];
|
||||||
|
@@ -397,9 +397,15 @@ func Test_argdelete()
|
|||||||
last
|
last
|
||||||
argdelete %
|
argdelete %
|
||||||
call assert_equal(['b'], argv())
|
call assert_equal(['b'], argv())
|
||||||
call assert_fails('argdelete', 'E471:')
|
call assert_fails('argdelete', 'E610:')
|
||||||
call assert_fails('1,100argdelete', 'E16:')
|
call assert_fails('1,100argdelete', 'E16:')
|
||||||
%argd
|
|
||||||
|
call Reset_arglist()
|
||||||
|
args a b c d
|
||||||
|
next
|
||||||
|
argdel
|
||||||
|
call Assert_argc(['a', 'c', 'd'])
|
||||||
|
%argdel
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_argdelete_completion()
|
func Test_argdelete_completion()
|
||||||
|
@@ -42,9 +42,7 @@ describe('argument list commands', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('test that argadd() works', function()
|
it('test that argadd() works', function()
|
||||||
-- Fails with “E474: Invalid argument”. Not sure whether it is how it is
|
command('%argdelete')
|
||||||
-- supposed to behave.
|
|
||||||
-- command('%argdelete')
|
|
||||||
command('argadd a b c')
|
command('argadd a b c')
|
||||||
eq(0, eval('argidx()'))
|
eq(0, eval('argidx()'))
|
||||||
|
|
||||||
@@ -176,9 +174,14 @@ describe('argument list commands', function()
|
|||||||
command('last')
|
command('last')
|
||||||
command('argdelete %')
|
command('argdelete %')
|
||||||
eq({'b'}, eval('argv()'))
|
eq({'b'}, eval('argv()'))
|
||||||
assert_fails('argdelete', 'E471:')
|
assert_fails('argdelete', 'E610:')
|
||||||
assert_fails('1,100argdelete', 'E16:')
|
assert_fails('1,100argdelete', 'E16:')
|
||||||
command('%argd')
|
reset_arglist()
|
||||||
|
command('args a b c d')
|
||||||
|
command('next')
|
||||||
|
command('argdel')
|
||||||
|
eq({'a', 'c', 'd'}, eval('argv()'))
|
||||||
|
command('%argdel')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('test for the :next, :prev, :first, :last, :rewind commands', function()
|
it('test for the :next, :prev, :first, :last, :rewind commands', function()
|
||||||
|
Reference in New Issue
Block a user