James McCoy wrote:
> 
> > > According to “:help 'formatexpr'”,
> > > 
> > >   The expression is also evaluated when 'textwidth' is set and adding
> > >   text beyond that limit.
> > > 
> > > However, even when 'formatoptions' doesn't contain "a", one can see that
> > > a set 'formatexpr' is called every time a character is typed, regardless
> > > of whether 'textwidth' is exceeded.  In fact, most of the (rather few)
> > > uses of 'formatexpr' which explicitly handle insert-mode reformatting
> > > have added the check that the help claims to already be doing.
> > > 
> > > In order to reduce the amount of boilerplate in scripts and conform
> > > better to the help, the attached patch performs this check for the user.
> > > Note, 'formatexpr' will still be called if the cursor is < 'textwidth'
> > > but other conditions necessitate formatting (like the "a" formatoption).
> > 
> > Perhaps we need to update the documentation.  The problem is that
> > computing virtcol is expensive.  It should at least use the cached value
> > w_virtcol, if it's valid.
> > 
> > I also think that if we have this check for using 'formatexpr', then it
> > should also be used for the internal formatting.
> 
> The internal formatting already performs this check.  That's where I got
> the virtcol check.
> 
> In fact, get_nolist_virtcol() uses validate_virtcol() to only recompute
> w_virtcol when needed, so it looks like the cached value is already used
> when appropriate.

I see.  Hmm, I'm not 100% sure that skipping 'formatexpr' will always work.
But it is documented that way.  And all tests pass.  So let's include
this patch and await anybody reporting problems.

-- 
Not too long ago, a keyboard was something to make music with...

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui