0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

updated for version 7.4.658

Problem:    'formatexpr' is evaluated too often.
Solution:   Only invoke it when beyond the 'textwidth' column, as it is
            documented. (James McCoy)
This commit is contained in:
Bram Moolenaar
2015-03-08 14:48:49 +01:00
parent ab11a5914b
commit 0f8dd840fc
2 changed files with 10 additions and 4 deletions

View File

@@ -5879,8 +5879,9 @@ insertchar(c, flags, second_indent)
char_u *p; char_u *p;
#endif #endif
int fo_ins_blank; int fo_ins_blank;
int force_format = flags & INSCHAR_FORMAT;
textwidth = comp_textwidth(flags & INSCHAR_FORMAT); textwidth = comp_textwidth(force_format);
fo_ins_blank = has_format_option(FO_INS_BLANK); fo_ins_blank = has_format_option(FO_INS_BLANK);
/* /*
@@ -5899,7 +5900,7 @@ insertchar(c, flags, second_indent)
* before 'textwidth' * before 'textwidth'
*/ */
if (textwidth > 0 if (textwidth > 0
&& ((flags & INSCHAR_FORMAT) && (force_format
|| (!vim_iswhite(c) || (!vim_iswhite(c)
&& !((State & REPLACE_FLAG) && !((State & REPLACE_FLAG)
#ifdef FEAT_VREPLACE #ifdef FEAT_VREPLACE
@@ -5917,8 +5918,11 @@ insertchar(c, flags, second_indent)
* when 'formatexpr' isn't set or it returns non-zero. */ * when 'formatexpr' isn't set or it returns non-zero. */
#if defined(FEAT_EVAL) #if defined(FEAT_EVAL)
int do_internal = TRUE; int do_internal = TRUE;
colnr_T virtcol = get_nolist_virtcol()
+ char2cells(c != NUL ? c : gchar_cursor());
if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0) if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0
&& (force_format || virtcol > (colnr_T)textwidth))
{ {
do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0); do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0);
/* It may be required to save for undo again, e.g. when setline() /* It may be required to save for undo again, e.g. when setline()

View File

@@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
658,
/**/ /**/
657, 657,
/**/ /**/