Hi Bram,
On Sat, Nov 5, 2016 at 12:59 PM, Bram Moolenaar
<[email protected]> wrote:
>
>
> Daniel Hahler wrote:
>
>> Here is a test case:
>>
>> ```vim
>> set errorformat=%m
>> lgetexpr '?'
>>
>> try
>> call DoesNotExit()
>> catch
>> lgetexpr '1'
>> finally
>> lgetexpr '1'
>> endtry
>>
>> if getloclist(0)[0].text != 1
>> echoerr 'laddexpr was not called'
>> endif
>> ```
>>
>> What about using `aborting()` instead of `did_throw || force_abort`?
>> But even then it seems strange to handle it there like this,
>> especially for cases where no autocommand has been called (and the
>> status might not have been checked before, in case some ran
>> successfully).
>
> We can check if apply_autocmds returns TRUE and use aborting().
> How about this:
>
Your change looks good to me. I am attaching a diff with your changes
and the test from Daniel.
- Yegappan
--
--
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/quickfix.c b/src/quickfix.c
index 5bd1257..b303b54 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3448,11 +3448,11 @@ ex_make(exarg_T *eap)
}
if (au_name != NULL)
{
- apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
- curbuf->b_fname, TRUE, curbuf);
+ if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
+ curbuf->b_fname, TRUE, curbuf))
# ifdef FEAT_EVAL
- if (did_throw || force_abort)
- return;
+ if (aborting())
+ return;
# endif
}
#endif
@@ -3972,10 +3972,12 @@ ex_vimgrep(exarg_T *eap)
}
if (au_name != NULL)
{
- apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
- curbuf->b_fname, TRUE, curbuf);
- if (did_throw || force_abort)
- return;
+ if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
+ curbuf->b_fname, TRUE, curbuf))
+#ifdef FEAT_EVAL
+ if (aborting())
+ return;
+#endif
}
#endif
@@ -4877,11 +4879,11 @@ ex_cbuffer(exarg_T *eap)
}
if (au_name != NULL)
{
- apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
- curbuf->b_fname, TRUE, curbuf);
+ if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
+ curbuf->b_fname, TRUE, curbuf))
# ifdef FEAT_EVAL
- if (did_throw || force_abort)
- return;
+ if (aborting())
+ return;
# endif
}
#endif
@@ -4968,11 +4970,11 @@ ex_cexpr(exarg_T *eap)
}
if (au_name != NULL)
{
- apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
- curbuf->b_fname, TRUE, curbuf);
+ if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
+ curbuf->b_fname, TRUE, curbuf))
# ifdef FEAT_EVAL
- if (did_throw || force_abort)
- return;
+ if (aborting())
+ return;
# endif
}
#endif
@@ -5044,10 +5046,12 @@ ex_helpgrep(exarg_T *eap)
}
if (au_name != NULL)
{
- apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
- curbuf->b_fname, TRUE, curbuf);
- if (did_throw || force_abort)
- return;
+ if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
+ curbuf->b_fname, TRUE, curbuf))
+#ifdef FEAT_EVAL
+ if (aborting())
+ return;
+#endif
}
#endif
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 022c12a..118a015 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -1631,3 +1631,20 @@ function Test_Autocmd()
\ 'postcaddbuffer']
call assert_equal(l, g:acmds)
endfunction
+
+function! Test_Autocmd_Exception()
+ set efm=%m
+ lgetexpr '?'
+
+ try
+ call DoesNotExit()
+ catch
+ lgetexpr '1'
+ finally
+ lgetexpr '1'
+ endtry
+
+ call assert_equal('1', getloclist(0)[0].text)
+
+ set efm&vim
+endfunction