Monday, October 21, 2019

Re: [vim/vim] :cdo does not abort on error (and the test for it seems wrong) (#5102)

diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 81f2c8f5b..c83dd3f71 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -944,6 +944,7 @@ ex_listdo(exarg_T *eap)
tabpage_T *tp;
buf_T *buf = curbuf;
int next_fnum = 0;
+ int save_did_emsg;
#if defined(FEAT_SYN_HL)
char_u *save_ei = NULL;
#endif
@@ -1042,6 +1043,8 @@ ex_listdo(exarg_T *eap)
setpcmark();
listcmd_busy = TRUE; /* avoids setting pcmark below */

+ save_did_emsg = did_emsg;
+ did_emsg = FALSE;
while (!got_int && buf != NULL)
{
if (eap->cmdidx == CMD_argdo)
@@ -1130,7 +1133,7 @@ ex_listdo(exarg_T *eap)
if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo
|| eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
{
- if (i >= qf_size || i >= eap->line2)
+ if (did_emsg || i >= qf_size || i >= eap->line2)
break;

qf_idx = qf_get_cur_idx(eap);
@@ -1159,6 +1162,7 @@ ex_listdo(exarg_T *eap)
break;
}
listcmd_busy = FALSE;
+ did_emsg = save_did_emsg;
}

#if defined(FEAT_SYN_HL)
Hi,

On Mon, Oct 21, 2019 at 12:12 PM D. Ben Knoble <vim-dev-github@256bit.org> wrote:

@yegappan thanks for the comparison to the other do commands, for the explanation of the test, and for demonstrating that that definition of :cdo explains basically all the behavior.

It is still unexpected behavior, and here is why:

:help :cdo        <			When the current file can't be |abandon|ed and the [!]    			is not present, the command fails.    			When an error is detected execution stops.    			The last buffer (or where an error occurred) becomes    			the current buffer.    

I see where you might have a point re: abandoning buffers. But the help says: "When an error is detected execution stops." Does this mean an error in :cdo (like the aforementioned abandon failure)? Or does this mean an error in {cmd} given to :cdo? Most users (myself included) seem to believe it's the latter—are you clarifying it is the former? Either way, we must update the help to be unambiguous (and it may be more useful to use the latter as actual behavior, given that :cdo operates at each entry, like :global (which, in fact, stops at the first error)).



Hi,

Can you try the attached patch?

Thanks,
Yegappan
 

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAAW7x7%3DHdmW8dDS5vjb3UWBt%3DkcngMMQYj5Qy_C59pssmqV39w%40mail.gmail.com.

No comments: