Patch 7.3.1199
Problem:    When evaluating 'foldexpr' causes an error this is silently
            ignored and evaluation is retried every time.
Solution:   Set emsg_silent instead of emsg_off. Stop evaluating 'foldexpr' is
            it is causing errors.  (Christian Brabandt)
Files:      src/fold.c


*** ../vim-7.3.1198/src/fold.c  2012-08-29 15:22:14.000000000 +0200
--- src/fold.c  2013-06-15 16:57:24.000000000 +0200
***************
*** 1930,1937 ****
      char_u    *buf;
  {
      char_u    *text = NULL;
- 
  #ifdef FEAT_EVAL
      if (*wp->w_p_fdt != NUL)
      {
        char_u  dashes[MAX_LEVEL + 2];
--- 1930,1951 ----
      char_u    *buf;
  {
      char_u    *text = NULL;
  #ifdef FEAT_EVAL
+      /* an error occurred when evaluating 'fdt' setting */
+     static int            got_fdt_error = FALSE;
+     int                   save_did_emsg = did_emsg;
+     static win_T    *last_wp = NULL;
+     static linenr_T last_lnum = 0;
+ 
+     if (last_wp != wp || last_wp == NULL
+                                       || last_lnum > lnum || last_lnum == 0)
+       /* window changed, try evaluating foldtext setting once again */
+       got_fdt_error = FALSE;
+ 
+     if (!got_fdt_error)
+       /* a previous error should not abort evaluating 'foldexpr' */
+       did_emsg = FALSE;
+ 
      if (*wp->w_p_fdt != NUL)
      {
        char_u  dashes[MAX_LEVEL + 2];
***************
*** 1952,1970 ****
        dashes[level] = NUL;
        set_vim_var_string(VV_FOLDDASHES, dashes, -1);
        set_vim_var_nr(VV_FOLDLEVEL, (long)level);
-       save_curwin = curwin;
-       curwin = wp;
-       curbuf = wp->w_buffer;
  
!       ++emsg_off;
!       text = eval_to_string_safe(wp->w_p_fdt, NULL,
                         was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
!       --emsg_off;
  
!       curwin = save_curwin;
!       curbuf = curwin->w_buffer;
        set_vim_var_string(VV_FOLDDASHES, NULL, -1);
  
        if (text != NULL)
        {
            /* Replace unprintable characters, if there are any.  But
--- 1966,1997 ----
        dashes[level] = NUL;
        set_vim_var_string(VV_FOLDDASHES, dashes, -1);
        set_vim_var_nr(VV_FOLDLEVEL, (long)level);
  
!       /* skip evaluating foldtext on errors */
!       if (!got_fdt_error)
!       {
!           save_curwin = curwin;
!           curwin = wp;
!           curbuf = wp->w_buffer;
! 
!           ++emsg_silent; /* handle exceptions, but don't display errors */
!           text = eval_to_string_safe(wp->w_p_fdt, NULL,
                         was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
!           --emsg_silent;
! 
!           if (text == NULL || did_emsg)
!               got_fdt_error = TRUE;
  
!           curwin = save_curwin;
!           curbuf = curwin->w_buffer;
!       }
!       last_lnum = lnum;
!       last_wp   = wp;
        set_vim_var_string(VV_FOLDDASHES, NULL, -1);
  
+       if (!did_emsg && save_did_emsg)
+           did_emsg = save_did_emsg;
+ 
        if (text != NULL)
        {
            /* Replace unprintable characters, if there are any.  But
*** ../vim-7.3.1198/src/version.c       2013-06-15 16:47:31.000000000 +0200
--- src/version.c       2013-06-15 16:53:16.000000000 +0200
***************
*** 730,731 ****
--- 730,733 ----
  {   /* Add new patch number below this line */
+ /**/
+     1199,
  /**/

-- 
'Psychologist' -- Someone who looks at everyone else when
an attractive woman enters the room.

 /// 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].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui