Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E490 foldopen error can’t be caught #48

Closed
GoogleCodeExporter opened this issue Aug 18, 2015 · 3 comments
Closed

E490 foldopen error can’t be caught #48

GoogleCodeExporter opened this issue Aug 18, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

>     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
Copy link
Author

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
Copy link
Author

Fixed by 7.3.637

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

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant