lalitmetkar / vim

Automatically exported from code.google.com/p/vim
0 stars 0 forks source link

E490 foldopen error can’t be caught #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. In a `vim -u NONE` do

    try | foldopen | catch | echom v:exception

What is the expected output? What do you see instead?
Expected: `Vim(foldopen):E490:...` message or such

Got:

    Error detected while processing :
    E490: No fold found

What version of the product are you using? On what operating system?

vim-7.3.382 from mercurial repository, Gentoo amd64

Original issue reported on code.google.com by zyx....@gmail.com on 13 Jan 2012 at 4:19

GoogleCodeExporter commented 9 years ago
>     try | foldopen | catch | echom v:exception

Of course, here should be trailing `| endtry`.

Original comment by zyx....@gmail.com on 13 Jan 2012 at 4:20

GoogleCodeExporter commented 9 years ago
Bram,
the problem is, the do{} while loop in ex_docmd.c in do_cmdline (line 1289).

If you look at this line:
&& !(did_emsg && used_getline
    && (getline_equal(fgetline, cookie, getexmodeline)
       || getline_equal(fgetline, cookie, getexline)))
Then the loop will always terminate, if did_emsg is set, even so a catch later 
on
might actually catch the error. So one probably also needs to check whether a 
try-clause if active and if those, let the loop continue.

Something like this patch:

diff --git a/src/ex_docmd.c b/src/ex_docmd.c
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1295,9 +1295,14 @@
                && cstack.cs_trylevel == 0
 #endif
            )
-           && !(did_emsg && used_getline
+           && !(used_getline
                            && (getline_equal(fgetline, cookie, getexmodeline)
-                              || getline_equal(fgetline, cookie, getexline)))
+                              || getline_equal(fgetline, cookie, getexline))
+           && did_emsg
+#ifdef FEAT_EVAL
+           && cstack.cs_trylevel == 0
+#endif
+           )
            && (next_cmdline != NULL
 #ifdef FEAT_EVAL
                        || cstack.cs_idx >= 0

This almost works, except when using an unknown command like this:
try | foobar|catch|echom v:exception|endtry
then the loop won't terminate.
I am not sure, what the correct abort condition needs to be
in this case.
(and I don't understand all conditions in that loop).

Original comment by chrisbr...@googlemail.com on 19 Aug 2012 at 12:57

GoogleCodeExporter commented 9 years ago
Fixed by 7.3.637

Original comment by chrisbr...@googlemail.com on 29 Sep 2014 at 4:58