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

26 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Yegappan Lakshmanan

nieprzeczytany,
21 paź 2019, 15:58:0621.10.2019
do D. Ben Knoble, Subscribed, vim...@googlegroups.com, vim_dev
Hi,

On Mon, Oct 21, 2019 at 12:12 PM D. Ben Knoble <vim-dev...@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
 
cdo.diff

Yegappan Lakshmanan

nieprzeczytany,
23 paź 2019, 13:09:0823.10.2019
do Ralf Schandl, vim_dev, D. Ben Knoble, Subscribed, vim...@googlegroups.com
Hi Ralf,

Thanks for testing the changes. See below.

On Tue, Oct 22, 2019 at 12:01 PM Ralf Schandl <ralf.s...@gmx.de> wrote:
>
> On 21.10.19 21:57, Yegappan Lakshmanan wrote:
> > Hi,
> >
> > On Mon, Oct 21, 2019 at 12:12 PM D. Ben Knoble
> ...
> >
> > Hi,
> >
> > Can you try the attached patch?
> >
> > Thanks,
> > Yegappan
> >
>
> Yegappan,
>
> thank you for providing a patch.
>
> It seems the patch didn't make it to GitHub. I pinged Ben & Dedowsdi via
> stackexchange. Hope they see it.
>
> I tested your patch in three ways:
>
> 1) :cdo s/TEST/HELLO/
>
> This will always fail, as there is no string "TEST" in any line. This
> error was ignored and :cdo worked on all lines.
>
> Is that intended?
>

Can you try the attached patch to see whether this is fixed? I am not able
to reproduce this behavior.

Thanks,
Yegappan

>
> 2) Calling a function from :cdo
>
> I build a qf list by :vimgrep for the word "dog". The function should
> replace "dog" with "cat". On the third invocation it throws an exception.
>
> 2.1) :cdo call Test_cdo()
>
> The first two entries were replaced and on the third entry a exception
> was thrown. Processing stops immediately. All other "dog"s were unchanged.
>
> 2.2) :cdo silent call Test_cdo()
>
> Acts like 2.1
>
> 2.3) :cdo silent! call Test_cdo()
>
> Ignores the exception and works on all entries of the qf list.
>
> 3) :cdo echo x
>
> The variable x is not defined. This was detected and the command was
> executed for the first entry of the qf list.
> With 'silent!' it processes all entries from the list.
>
> I'm not sure if the behavior in the first test case is intended. In the
> other two cases it worked like I expected.
>
> Regards,
> Ralf
>
cdo.diff
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0