Diff loses sync

56 views
Skip to first unread message

Gary Johnson

unread,
Jun 23, 2022, 9:36:06 PM6/23/22
to vim...@googlegroups.com
I've noticed for a while when diffing two versions of a file that
the two windows sometimes get out of sync. I created and attached
two files that exhibit this problem. For this example, I ran vim
version 8.2.5154 in an 80x24 xterm.

Steps to reproduce

1. Save the attached files to disk.
2. Start vim as

$ vimdiff -N -u NONE -i NONE demo_left demo_right

The display initially looks fine.
3. Move the cursor to the right window:

<C-W><C-W>

4. Move the cursor down five lines:

jjjjj

Note that when the cursor reaches the fifth line 6, containing
"Lorem", the left window scrolls to display common block one in
roughly the center while the right window remains unchanged,
like this. (I removed eight columns from each window to make it
fit in the width of a standard email page.)

------------------------------| line 1
------------------------------| line 2
------------------------------| line 3
------------------------------| line 4
------------------------------|
------------------------------| Lorem
------------------------------| ipsum
------------------------------| dolor
------------------------------| sit
------------------------------| amet,
// Common block | consectetur
// one | adipiscing
// containing | elit.
// four lines | Etiam
| luctus
------------------------------| lectus
------------------------------| sodales,
------------------------------| dictum
------------------------------| augue
------------------------------| vel,
------------------------------| molestie
------------------------------| augue.
demo_left 6,1 85% demo_right 6,1 Top

5. Move the cursor down to the bottom of the window and one line
more. The right window scrolls one line as expected and the
left window scrolls to align itself properly with the right
window.

6. Use the j key to move further down in the right buffer and more
odd things happen, as when the cursor moves to line 39,
containing "Vestibulum". The left window scrolls to show the
last 3 lines of common block one at the top and the first line
of common block two at the bottom.

Expected behavior

I expect the left window to remain in sync with the right
window, displaying common buffer lines on the same screen line.

Version of Vim

8.2.5154

Environment

Operating system: Ubuntu 20.04
Terminal: XTerm(370)
Value of $TERM: xterm-256color
Shell: bash 5.0.17(1)-release

Regards,
Gary
demo_left
demo_right

Bram Moolenaar

unread,
Jun 24, 2022, 7:39:31 AM6/24/22
to vim...@googlegroups.com, Gary Johnson
Thanks for providing a good repro case. The window height also matters,
it must not have too many lines.

I'll fix it. Please check for any places that then might fail, the
rules about 'scrollbind' and 'cursorbind' are tricky.

--
EXPERIENCE - experience is a wonderful thing. It enables you to
recognise a mistake when you make it again.

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

Gary Johnson

unread,
Jun 24, 2022, 12:41:44 PM6/24/22
to vim...@googlegroups.com
On 2022-06-24, Bram Moolenaar wrote:
> Gary Johnson wrote:
>
> > I've noticed for a while when diffing two versions of a file that
> > the two windows sometimes get out of sync. I created and attached
> > two files that exhibit this problem. For this example, I ran vim
> > version 8.2.5154 in an 80x24 xterm.
> >
> > Steps to reproduce

[...]

> Thanks for providing a good repro case. The window height also matters,
> it must not have too many lines.
>
> I'll fix it. Please check for any places that then might fail, the
> rules about 'scrollbind' and 'cursorbind' are tricky.

Thank you. The new version worked great on the files I was working
on when I reported the problem. I'll continue to watch for any
other issues.

Regards,
Gary

Reply all
Reply to author
Forward
0 new messages