On Fri, Feb 27, 2015 at 03:04:16PM +0100, Bram Moolenaar wrote:
> 
> 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.

Cheers,
-- 
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <[email protected]>

-- 
-- 
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.

Attachment: signature.asc
Description: Digital signature

Raspunde prin e-mail lui