Karsten Hopp 181767
To: vim_dev@googlegroups.com
Karsten Hopp 181767
Subject: Patch 7.3.1199
Karsten Hopp 181767
Fcc: outbox
Karsten Hopp 181767
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 181767
Mime-Version: 1.0
Karsten Hopp 181767
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 181767
Content-Transfer-Encoding: 8bit
Karsten Hopp 181767
------------
Karsten Hopp 181767
Karsten Hopp 181767
Patch 7.3.1199
Karsten Hopp 181767
Problem:    When evaluating 'foldexpr' causes an error this is silently
Karsten Hopp 181767
	    ignored and evaluation is retried every time.
Karsten Hopp 181767
Solution:   Set emsg_silent instead of emsg_off. Stop evaluating 'foldexpr' is
Karsten Hopp 181767
	    it is causing errors.  (Christian Brabandt)
Karsten Hopp 181767
Files:	    src/fold.c
Karsten Hopp 181767
Karsten Hopp 181767
Karsten Hopp 181767
*** ../vim-7.3.1198/src/fold.c	2012-08-29 15:22:14.000000000 +0200
Karsten Hopp 181767
--- src/fold.c	2013-06-15 16:57:24.000000000 +0200
Karsten Hopp 181767
***************
Karsten Hopp 181767
*** 1930,1937 ****
Karsten Hopp 181767
      char_u	*buf;
Karsten Hopp 181767
  {
Karsten Hopp 181767
      char_u	*text = NULL;
Karsten Hopp 181767
- 
Karsten Hopp 181767
  #ifdef FEAT_EVAL
Karsten Hopp 181767
      if (*wp->w_p_fdt != NUL)
Karsten Hopp 181767
      {
Karsten Hopp 181767
  	char_u	dashes[MAX_LEVEL + 2];
Karsten Hopp 181767
--- 1930,1951 ----
Karsten Hopp 181767
      char_u	*buf;
Karsten Hopp 181767
  {
Karsten Hopp 181767
      char_u	*text = NULL;
Karsten Hopp 181767
  #ifdef FEAT_EVAL
Karsten Hopp 181767
+      /* an error occurred when evaluating 'fdt' setting */
Karsten Hopp 181767
+     static int	    got_fdt_error = FALSE;
Karsten Hopp 181767
+     int		    save_did_emsg = did_emsg;
Karsten Hopp 181767
+     static win_T    *last_wp = NULL;
Karsten Hopp 181767
+     static linenr_T last_lnum = 0;
Karsten Hopp 181767
+ 
Karsten Hopp 181767
+     if (last_wp != wp || last_wp == NULL
Karsten Hopp 181767
+ 					|| last_lnum > lnum || last_lnum == 0)
Karsten Hopp 181767
+ 	/* window changed, try evaluating foldtext setting once again */
Karsten Hopp 181767
+ 	got_fdt_error = FALSE;
Karsten Hopp 181767
+ 
Karsten Hopp 181767
+     if (!got_fdt_error)
Karsten Hopp 181767
+ 	/* a previous error should not abort evaluating 'foldexpr' */
Karsten Hopp 181767
+ 	did_emsg = FALSE;
Karsten Hopp 181767
+ 
Karsten Hopp 181767
      if (*wp->w_p_fdt != NUL)
Karsten Hopp 181767
      {
Karsten Hopp 181767
  	char_u	dashes[MAX_LEVEL + 2];
Karsten Hopp 181767
***************
Karsten Hopp 181767
*** 1952,1970 ****
Karsten Hopp 181767
  	dashes[level] = NUL;
Karsten Hopp 181767
  	set_vim_var_string(VV_FOLDDASHES, dashes, -1);
Karsten Hopp 181767
  	set_vim_var_nr(VV_FOLDLEVEL, (long)level);
Karsten Hopp 181767
- 	save_curwin = curwin;
Karsten Hopp 181767
- 	curwin = wp;
Karsten Hopp 181767
- 	curbuf = wp->w_buffer;
Karsten Hopp 181767
  
Karsten Hopp 181767
! 	++emsg_off;
Karsten Hopp 181767
! 	text = eval_to_string_safe(wp->w_p_fdt, NULL,
Karsten Hopp 181767
  			 was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
Karsten Hopp 181767
! 	--emsg_off;
Karsten Hopp 181767
  
Karsten Hopp 181767
! 	curwin = save_curwin;
Karsten Hopp 181767
! 	curbuf = curwin->w_buffer;
Karsten Hopp 181767
  	set_vim_var_string(VV_FOLDDASHES, NULL, -1);
Karsten Hopp 181767
  
Karsten Hopp 181767
  	if (text != NULL)
Karsten Hopp 181767
  	{
Karsten Hopp 181767
  	    /* Replace unprintable characters, if there are any.  But
Karsten Hopp 181767
--- 1966,1997 ----
Karsten Hopp 181767
  	dashes[level] = NUL;
Karsten Hopp 181767
  	set_vim_var_string(VV_FOLDDASHES, dashes, -1);
Karsten Hopp 181767
  	set_vim_var_nr(VV_FOLDLEVEL, (long)level);
Karsten Hopp 181767
  
Karsten Hopp 181767
! 	/* skip evaluating foldtext on errors */
Karsten Hopp 181767
! 	if (!got_fdt_error)
Karsten Hopp 181767
! 	{
Karsten Hopp 181767
! 	    save_curwin = curwin;
Karsten Hopp 181767
! 	    curwin = wp;
Karsten Hopp 181767
! 	    curbuf = wp->w_buffer;
Karsten Hopp 181767
! 
Karsten Hopp 181767
! 	    ++emsg_silent; /* handle exceptions, but don't display errors */
Karsten Hopp 181767
! 	    text = eval_to_string_safe(wp->w_p_fdt, NULL,
Karsten Hopp 181767
  			 was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
Karsten Hopp 181767
! 	    --emsg_silent;
Karsten Hopp 181767
! 
Karsten Hopp 181767
! 	    if (text == NULL || did_emsg)
Karsten Hopp 181767
! 		got_fdt_error = TRUE;
Karsten Hopp 181767
  
Karsten Hopp 181767
! 	    curwin = save_curwin;
Karsten Hopp 181767
! 	    curbuf = curwin->w_buffer;
Karsten Hopp 181767
! 	}
Karsten Hopp 181767
! 	last_lnum = lnum;
Karsten Hopp 181767
! 	last_wp   = wp;
Karsten Hopp 181767
  	set_vim_var_string(VV_FOLDDASHES, NULL, -1);
Karsten Hopp 181767
  
Karsten Hopp 181767
+ 	if (!did_emsg && save_did_emsg)
Karsten Hopp 181767
+ 	    did_emsg = save_did_emsg;
Karsten Hopp 181767
+ 
Karsten Hopp 181767
  	if (text != NULL)
Karsten Hopp 181767
  	{
Karsten Hopp 181767
  	    /* Replace unprintable characters, if there are any.  But
Karsten Hopp 181767
*** ../vim-7.3.1198/src/version.c	2013-06-15 16:47:31.000000000 +0200
Karsten Hopp 181767
--- src/version.c	2013-06-15 16:53:16.000000000 +0200
Karsten Hopp 181767
***************
Karsten Hopp 181767
*** 730,731 ****
Karsten Hopp 181767
--- 730,733 ----
Karsten Hopp 181767
  {   /* Add new patch number below this line */
Karsten Hopp 181767
+ /**/
Karsten Hopp 181767
+     1199,
Karsten Hopp 181767
  /**/
Karsten Hopp 181767
Karsten Hopp 181767
-- 
Karsten Hopp 181767
'Psychologist' -- Someone who looks at everyone else when
Karsten Hopp 181767
an attractive woman enters the room.
Karsten Hopp 181767
Karsten Hopp 181767
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 181767
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 181767
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 181767
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///