Scope of 'scrollopt' too much?

8 views
Skip to first unread message

Gary Johnson

unread,
Feb 24, 2023, 8:14:53 PM2/24/23
to vim...@googlegroups.com
I've noticed a problem when I have multiple tab pages open, each
containing two windows that are diff'd, and I execute :diffoff! or
:tabclose! in one of the tabs. Either one of those commands resets
the value of 'scrollopt' from "ver,jump,hor" to "ver,jump". The
problem is that 'scrollopt' is a global options, so its reset value
affects the diffs in all the tab pages, not just the one in which
:diffoff! or :tabclose! was executed.

I encounter this problem frequently when using the Fugitive ":Git
difftool -y" command and close one of the tabs. It is not a bug in
Fugitive; I can reproduce it starting with "$ vim -N -u NONE -i
NONE -p file1 file2".

I could execute :diffoff again after :diffoff! as mentioned in
":help :diffoff", but that's annoying and not even possible in the
:tabclose! case.

Would it be possible to fix this problem, perhaps by doing something
like making 'scrollopt' tab-local (I know there's currently no such
thing) or resetting it to "ver,jump" only when no window in any tab
page is in diff mode?

Regards,
Gary

Bram Moolenaar

unread,
Feb 25, 2023, 7:00:25 AM2/25/23
to vim...@googlegroups.com, Gary Johnson

> I've noticed a problem when I have multiple tab pages open, each
> containing two windows that are diff'd, and I execute :diffoff! or
> :tabclose! in one of the tabs. Either one of those commands resets
> the value of 'scrollopt' from "ver,jump,hor" to "ver,jump". The
> problem is that 'scrollopt' is a global options, so its reset value
> affects the diffs in all the tab pages, not just the one in which
> :diffoff! or :tabclose! was executed.

The ex_difoff() function removes "hor" from 'scrollopt' when there are
no windows in diff mode in the current tab.

> I encounter this problem frequently when using the Fugitive ":Git
> difftool -y" command and close one of the tabs. It is not a bug in
> Fugitive; I can reproduce it starting with "$ vim -N -u NONE -i
> NONE -p file1 file2".
>
> I could execute :diffoff again after :diffoff! as mentioned in
> ":help :diffoff", but that's annoying and not even possible in the
> :tabclose! case.
>
> Would it be possible to fix this problem, perhaps by doing something
> like making 'scrollopt' tab-local (I know there's currently no such
> thing) or resetting it to "ver,jump" only when no window in any tab
> page is in diff mode?

We don't have tab-local options yet, and implementing them will be some
work. It's also not clear if we need new commands or that :setlocal
could be used.

We could check in ex_diffoff() if there is a window in another tab still
in diff mode and not remove "hor" from 'scrollopt' then. I wonder if
that would work for everyone.

--
When I die, I want to go peacefully in my sleep like my grandfather.
Not screaming in terror, like his passengers.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages