Christian wrote:

> I see a potential problem when running `:s/../\=Function/gn` command.
> 
> If the function aborts, the sandbox might still be set, which causes an 
> unusable Vim. This just happened to me several times with some errors in 
> Function. However, when trying to reproduce, aborting() does not seem to 
> return True with a simple error (like undefined variable or so), so I 
> don't currently know how to create a test for that :(

I can reproduce this.  There actually is a check for this in
Test_nocatch_sub_failure_handling().  But it doesn't trigger the problem
there.  Ah, it doesn't use the "n" flag.  Then it indeed fails.

> So here is just the patch:
> 
> diff --git a/src/ex_cmds.c b/src/ex_cmds.c
> index b99e54bce..932e3d2f0 100644
> --- a/src/ex_cmds.c
> +++ b/src/ex_cmds.c
> @@ -4880,7 +4880,7 @@ do_sub(exarg_T *eap)
>      pos_T      old_cursor = curwin->w_cursor;
>      int                start_nsubs;
>  #ifdef FEAT_EVAL
> -    int                save_ma = 0;
> +    int                save_ma = curbuf->b_p_ma;
>  #endif
> 
>      cmd = eap->arg;
> @@ -5556,7 +5556,6 @@ do_sub(exarg_T *eap)
>                 if (subflags.do_count)
>                 {
>                     /* prevent accidentally changing the buffer by a function 
> */
> -                   save_ma = curbuf->b_p_ma;
>                     curbuf->b_p_ma = FALSE;
>                     sandbox++;
>                 }
> @@ -5571,12 +5570,9 @@ do_sub(exarg_T *eap)
>  #ifdef FEAT_EVAL
>                 // If getting the substitute string caused an error, don't do
>                 // the replacement.
> -               if (aborting())
> -                   goto skip;
> -
>                 // Don't keep flags set by a recursive call.
>                 subflags = subflags_save;
> -               if (subflags.do_count)
> +               if (aborting() || subflags.do_count)
>                 {
>                     curbuf->b_p_ma = save_ma;
>                     if (sandbox > 0)

Thanks, that should fix it.

-- 
If your company is not involved in something called "ISO 9000" you probably
have no idea what it is.  If your company _is_ involved in ISO 9000 then you
definitely have no idea what it is.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201905181141.x4IBff9A002691%40masaka.moolenaar.net.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui