On 24-Jun-15, Bram Moolenaar wrote:
> 
> Olaf Dabrunz wrote:
> 
> > On 21-Jun-15, Manuel Ortega wrote:
> > > Specifically, if you forget that diff mode is already off and you do
> > > :diffoff a second time, you will lose &scrollbind, &foldmethod, &wrap,
> > > etc if you had them set to something other than those defaults.  This is
> > > really annoying.  I kept wondering what happened to my folds!
> > > Sometimes I had &scrollbind on outside of diff mode, and I lost it after
> > > inadvertently doing a second :diffoff.
> > 
> > So the problem seems to be that ':diffoff' forgets about the saved
> > values when it is used the first time, so on the second ':diffoff' it
> > restores the defaults.
> > 
> > The patch below changes this so that the saved settings are never
> > forgotten.  And with the patch they get updated whenever ':diffthis' or
> > friends are used on a window that is not yet in 'diff' mode.
> > 
> > So a second ':diffthis' in a diff window does not overwrite the settings
> > saved when entering diff mode.  And a second ':diffoff' restores the
> > settings that were saved the last time when this window entered diff
> > mode.
> > 
> > A second ':diffoff' can of course still lose settings that you made
> > after the first ':diffoff'.  But I do not see a simple solution for
> > that.  Maybe you can live with that.
> > 
> > No documentation in the patch, because in my understanding the current
> > docs seem to imply this behavior:
> > 
> >     The ":diffoff" command resets the relevant options to the values
> >     they had when using |:diffsplit|, |:diffpatch| , |:diffthis|. or
> >     starting Vim in diff mode.  Otherwise they are set to their default
> >     value:
> > 
> > 
> > With the patch, ':diffoff' will only restore the defaults if the window
> > has never been in a diff.
> 
> Thanks, I guess this will work for everyone.
> 
> > Question to the list: should ':diffoff' *ever* restore default settings?
> > 
> > Maybe it is better to only restore settings that have been saved before,
> > when entering diff mode at some point, if that has happened at all.
> > 
> > Because if the window was never switched to diff mode, why should
> > ':diffoff' restore settings that have never been changed by diff mode,
> > and then to some arbitrary defaults?  Better leave these settings
> > untouched in that case?
> 
> Not sure if someone would type :diffoff without entering diff mode,
> other then doing this intentionally to get some options into a sane
> state.

Yes.  I think that this is a very specific set of options, and except
for displaying a diff I cannot come up with a situation where these
specific options must be set to a specific builtin default.

Also, depending on filetype and user preference, fdm and fdc have
specific values.  'wrap' can also depend on the filetype, user
preference and I sometimes adjust it for specific files.

This varies sufficiently that in order to use the defaults in :diffoff
effectively, I would need to remember if it recalls the right settings
for the current file.  This is more of a burden than helpful.

For sane defaults during testing, we have 'vim -u NONE -U NONE'.

-- 
Olaf Dabrunz (oda <at> fctrace.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