Karsten Hopp 2a1fb4
To: vim_dev@googlegroups.com
Karsten Hopp 2a1fb4
Subject: Patch 7.4.658
Karsten Hopp 2a1fb4
Fcc: outbox
Karsten Hopp 2a1fb4
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 2a1fb4
Mime-Version: 1.0
Karsten Hopp 2a1fb4
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 2a1fb4
Content-Transfer-Encoding: 8bit
Karsten Hopp 2a1fb4
------------
Karsten Hopp 2a1fb4
Karsten Hopp 2a1fb4
Patch 7.4.658
Karsten Hopp 2a1fb4
Problem:    'formatexpr' is evaluated too often.
Karsten Hopp 2a1fb4
Solution:   Only invoke it when beyond the 'textwidth' column, as it is
Karsten Hopp 2a1fb4
	    documented. (James McCoy)
Karsten Hopp 2a1fb4
Files:	    src/edit.c
Karsten Hopp 2a1fb4
Karsten Hopp 2a1fb4
Karsten Hopp 2a1fb4
*** ../vim-7.4.657/src/edit.c	2015-03-05 18:08:38.893104412 +0100
Karsten Hopp 2a1fb4
--- src/edit.c	2015-03-08 14:42:36.495743590 +0100
Karsten Hopp 2a1fb4
***************
Karsten Hopp 2a1fb4
*** 5879,5886 ****
Karsten Hopp 2a1fb4
      char_u	*p;
Karsten Hopp 2a1fb4
  #endif
Karsten Hopp 2a1fb4
      int		fo_ins_blank;
Karsten Hopp 2a1fb4
  
Karsten Hopp 2a1fb4
!     textwidth = comp_textwidth(flags & INSCHAR_FORMAT);
Karsten Hopp 2a1fb4
      fo_ins_blank = has_format_option(FO_INS_BLANK);
Karsten Hopp 2a1fb4
  
Karsten Hopp 2a1fb4
      /*
Karsten Hopp 2a1fb4
--- 5879,5887 ----
Karsten Hopp 2a1fb4
      char_u	*p;
Karsten Hopp 2a1fb4
  #endif
Karsten Hopp 2a1fb4
      int		fo_ins_blank;
Karsten Hopp 2a1fb4
+     int		force_format = flags & INSCHAR_FORMAT;
Karsten Hopp 2a1fb4
  
Karsten Hopp 2a1fb4
!     textwidth = comp_textwidth(force_format);
Karsten Hopp 2a1fb4
      fo_ins_blank = has_format_option(FO_INS_BLANK);
Karsten Hopp 2a1fb4
  
Karsten Hopp 2a1fb4
      /*
Karsten Hopp 2a1fb4
***************
Karsten Hopp 2a1fb4
*** 5899,5905 ****
Karsten Hopp 2a1fb4
       *	      before 'textwidth'
Karsten Hopp 2a1fb4
       */
Karsten Hopp 2a1fb4
      if (textwidth > 0
Karsten Hopp 2a1fb4
! 	    && ((flags & INSCHAR_FORMAT)
Karsten Hopp 2a1fb4
  		|| (!vim_iswhite(c)
Karsten Hopp 2a1fb4
  		    && !((State & REPLACE_FLAG)
Karsten Hopp 2a1fb4
  #ifdef FEAT_VREPLACE
Karsten Hopp 2a1fb4
--- 5900,5906 ----
Karsten Hopp 2a1fb4
       *	      before 'textwidth'
Karsten Hopp 2a1fb4
       */
Karsten Hopp 2a1fb4
      if (textwidth > 0
Karsten Hopp 2a1fb4
! 	    && (force_format
Karsten Hopp 2a1fb4
  		|| (!vim_iswhite(c)
Karsten Hopp 2a1fb4
  		    && !((State & REPLACE_FLAG)
Karsten Hopp 2a1fb4
  #ifdef FEAT_VREPLACE
Karsten Hopp 2a1fb4
***************
Karsten Hopp 2a1fb4
*** 5916,5924 ****
Karsten Hopp 2a1fb4
  	/* Format with 'formatexpr' when it's set.  Use internal formatting
Karsten Hopp 2a1fb4
  	 * when 'formatexpr' isn't set or it returns non-zero. */
Karsten Hopp 2a1fb4
  #if defined(FEAT_EVAL)
Karsten Hopp 2a1fb4
! 	int do_internal = TRUE;
Karsten Hopp 2a1fb4
  
Karsten Hopp 2a1fb4
! 	if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0)
Karsten Hopp 2a1fb4
  	{
Karsten Hopp 2a1fb4
  	    do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0);
Karsten Hopp 2a1fb4
  	    /* It may be required to save for undo again, e.g. when setline()
Karsten Hopp 2a1fb4
--- 5917,5928 ----
Karsten Hopp 2a1fb4
  	/* Format with 'formatexpr' when it's set.  Use internal formatting
Karsten Hopp 2a1fb4
  	 * when 'formatexpr' isn't set or it returns non-zero. */
Karsten Hopp 2a1fb4
  #if defined(FEAT_EVAL)
Karsten Hopp 2a1fb4
! 	int     do_internal = TRUE;
Karsten Hopp 2a1fb4
! 	colnr_T virtcol = get_nolist_virtcol()
Karsten Hopp 2a1fb4
! 				  + char2cells(c != NUL ? c : gchar_cursor());
Karsten Hopp 2a1fb4
  
Karsten Hopp 2a1fb4
! 	if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0
Karsten Hopp 2a1fb4
! 		&& (force_format || virtcol > (colnr_T)textwidth))
Karsten Hopp 2a1fb4
  	{
Karsten Hopp 2a1fb4
  	    do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0);
Karsten Hopp 2a1fb4
  	    /* It may be required to save for undo again, e.g. when setline()
Karsten Hopp 2a1fb4
*** ../vim-7.4.657/src/version.c	2015-03-06 22:00:06.817456968 +0100
Karsten Hopp 2a1fb4
--- src/version.c	2015-03-08 14:46:45.836912488 +0100
Karsten Hopp 2a1fb4
***************
Karsten Hopp 2a1fb4
*** 743,744 ****
Karsten Hopp 2a1fb4
--- 743,746 ----
Karsten Hopp 2a1fb4
  {   /* Add new patch number below this line */
Karsten Hopp 2a1fb4
+ /**/
Karsten Hopp 2a1fb4
+     658,
Karsten Hopp 2a1fb4
  /**/
Karsten Hopp 2a1fb4
Karsten Hopp 2a1fb4
-- 
Karsten Hopp 2a1fb4
I have to exercise early in the morning before my brain
Karsten Hopp 2a1fb4
figures out what I'm doing.
Karsten Hopp 2a1fb4
Karsten Hopp 2a1fb4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 2a1fb4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 2a1fb4
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 2a1fb4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///