mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
vim-patch:7.4.658
Problem: 'formatexpr' is evaluated too often.
Solution: Only invoke it when beyond the 'textwidth' column, as it is
documented. (James McCoy)
0f8dd840fc
This commit is contained in:
parent
f183cc14de
commit
815fe24604
@ -5017,8 +5017,9 @@ insertchar (
|
||||
int textwidth;
|
||||
char_u *p;
|
||||
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);
|
||||
|
||||
/*
|
||||
@ -5037,7 +5038,7 @@ insertchar (
|
||||
* before 'textwidth'
|
||||
*/
|
||||
if (textwidth > 0
|
||||
&& ((flags & INSCHAR_FORMAT)
|
||||
&& (force_format
|
||||
|| (!ascii_iswhite(c)
|
||||
&& !((State & REPLACE_FLAG)
|
||||
&& !(State & VREPLACE_FLAG)
|
||||
@ -5051,8 +5052,11 @@ insertchar (
|
||||
/* Format with 'formatexpr' when it's set. Use internal formatting
|
||||
* when 'formatexpr' isn't set or it returns non-zero. */
|
||||
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);
|
||||
/* It may be required to save for undo again, e.g. when setline()
|
||||
* was called. */
|
||||
|
@ -338,7 +338,7 @@ static int included_patches[] = {
|
||||
// 661,
|
||||
660,
|
||||
659,
|
||||
// 658,
|
||||
658,
|
||||
// 657 NA
|
||||
// 656,
|
||||
// 655,
|
||||
|
Loading…
Reference in New Issue
Block a user