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
--
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220629001636.GC12539%40phoenix.
Mary had a little lamb,
Its fleece was white at snow,
And everywhere that Mary went,
The lamb was sure to go.
Mary had a little goat,
Its fleece was white at snow,
And everywhere that Mary went,
The goat was sure to go.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam luctus lectus
sodales, dictum augue vel, molestie augue. Duis sit amet rhoncus justo. Nullam
posuere risus semper magna commodo scelerisque. Duis et venenatis sem. In
rhoncus augue sed tempor mattis. Mauris id aliquet odio. Sed eget est aliquam,
pulvinar enim elementum, ultricies lorem. Integer egestas dui dui, nec viverra
felis semper a. Mauris sed sodales est. Nulla ultrices nulla vitae sem
convallis, ut tincidunt enim fermentum. Pellentesque nulla nisi, pellentesque
a augue sit amet, vulputate ornare massa. Phasellus ultrices vitae augue vitae
faucibus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam luctus lectus
sodales, dictum augue vel, molestie augue. Duis sit amet rhoncus justo. Nullam
posuere risus semper minima commodo scelerisque. Duis et venenatis sem. In
rhoncus augue sed tempor mattis. Mauris id aliquet odio. Sed eget est aliquam,
pulvinar enim elementum, ultricies lorem. Float egestas dui dui, nec viverra
felis semper a. Mauris sed sodales est. Nulla ultrices nulla vitae sem
convallis, ut tincidunt enim fermentum. Pellentesque nulla nisi, pellentesque
a augue sit amet, vulputate ornare massa. Phasellus ultrices vitae augue vitae
faucibus.