Yukihiro Nakadaira wrote:

> When using %! item in 'statusline' option, Vim sometimes shows an error
> and sometimes crash.
>
>   vimrc.vim:
>     set statusline=%!MyStatusLine()
>     set laststatus=2
>     function MyStatusLine()
>       return ""
>     endfunction
>
>   $ gvim -u vimrc.vim
>   Error detected while processing function MyStatusLine:
>   E121: Undefined variable: MyStatusLine
>   Error detected while processing function MyStatusLine:
>   E15: Invalid expression: MyStatusLine
>   E15: Invalid expression: ~W^Iá3~L          (message is random text)
>
> I am using GTK2 GUI.  I saw the error at startup and when using
> scrollbar.
>
> The error can be reproduced by using :redraw! command in MyStatusLine().
>
>     function MyStatusLine()
>       redraw!
>       return ""
>     endfunction

Hi

I can reproduce the crash too with the redraw! inside the
MyStatusLine() function as you describe.

The attached patch fixes it for me but please verify it and review it.
Patch prevents recursive call of redraw_custum_statusline().

Regards
-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Index: screen.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/screen.c,v
retrieving revision 1.123
diff -c -r1.123 screen.c
*** screen.c	29 Jul 2009 14:24:32 -0000	1.123
--- screen.c	2 Nov 2009 19:03:43 -0000
***************
*** 5900,5906 ****
  redraw_custum_statusline(wp)
      win_T	    *wp;
  {
!     int	save_called_emsg = called_emsg;
  
      called_emsg = FALSE;
      win_redr_custom(wp, FALSE);
--- 5900,5911 ----
  redraw_custum_statusline(wp)
      win_T	    *wp;
  {
!     static int	    entered = FALSE;		/* avoid recursiveness */
!     int		    save_called_emsg = called_emsg;
! 
!     if (entered)
! 	return;
!     entered = TRUE;
  
      called_emsg = FALSE;
      win_redr_custom(wp, FALSE);
***************
*** 5909,5914 ****
--- 5914,5920 ----
  		(char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL
  					? OPT_LOCAL : OPT_GLOBAL), SID_ERROR);
      called_emsg |= save_called_emsg;
+     entered = FALSE;
  }
  #endif
  

Raspunde prin e-mail lui