Gary Johnson
unread,Jun 28, 2022, 8:16:33 PM6/28/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vim...@googlegroups.com
I'm not sure this is bug, but it's not what I expect and I don't
know of a workaround.
I often use the Fugitive command ":Git difftool -y" to open a set of
tabs, each one containing a diff of the working tree version of
a file with some other version of that file. I sometimes use
a command such as CTRL-W_], :scscope or :new to open another window
to look at other uses or the definition of some variable.
If any of those commands opens a new buffer, that window and its new
buffer are not included in the diff. However, if any of those
commands opens an already-open buffer from another tab, and that
buffer was included in a diff in that tab, then the new window and
that existing buffer are added to the diff in the current tab.
Since the new window and its buffer are usually unrelated to the
windows and their buffers already in the current tab, the display
becomes a mess of change highlighting. Also, the new window is
scrollbound and cursorbound to the other windows, so scrolling
around in it drags the other windows along. Further, closing the
new window does not remove its buffer from the diff set, leaving the
highlighting mess.
It seems to me that since diff options are window-local and not
buffer-local, the fact that a buffer is included in a diff in one
tab should not follow it when it is opened in a different tab.
Steps to reproduce
1. Create a set of four files, a, b, c and d, such that a and
b have slight differences, c and d have slight differences, but
a and b are very different from c and d. The files I used are
attached.
2. Start vim:
$ vim -N -u NONE -i NONE
3. Execute the following.
:e b
:vert diffsplit a
:tabnew d
:vert diffsplit c
:wincmd w
4. Open some unrelated file in a new window, e.g.,
:new ~/.vim/vimrc
5. Browse around that file and note that the other windows are not
affected.
6. Close that window:
:close
7. Open one of the files already open in the other tab:
:new b
8. Note that the highlighting of all the lines in all the windows
in the current tab has changed to DiffAdd, DiffChange or
DiffDelete.
9. Close this window:
:close
10. Note that the highlighting of the two original windows remains
affected by the now-closed window.
Executing :diffoff in the new window will fix the problem
temporarily, but it comes back as soon as another existing,
diffed buffer is opened in that window.
Expected behavior
I expect a buffer opened in a new window to not be part of the
diff of other windows in that tab, regardless of whether it is
already open in some other tab and whether a window in which it
is open in that other tab is part of a diff.
Version of Vim
9.0.0
Environment
Operating system: Ubuntu 20.04
Terminal: XTerm(370)
Value of $TERM: xterm-256color
Shell: bash
Regards,
Gary