Wednesday, September 5, 2012

Diff 2 files with lines added at top of second file: confusing

Hi,
I noticed one scenario where vim is not showing me the diff as I expect.

I have 2 files, a.txt and b.txt that for that test (I have seen it on "real" files")
a.txt has 100 lines, each line with just a number. Looks like this
0
1
2
[...]

b.txt is same as on a, but I added a few lines at the top, all with just a -1. Looks like this
-1
-1
-1
0
1
2
3
[...]

If I run gvim -d b.txt a.txt, things are as I expect: I see the added block of -1, few common lines, then the rest is folded.

But if I run gvim -d a.txt b.txt, I don't initially see the block of -1. The vertical scrollbar is all the way to the top (I can't scroll up), the first 6 lines are shown with no diff, the rest is folded. If I just scroll with the mouse while on window of file a, nothing happens. Same if gg on a. But if click on the window where b is, the scroll bar is not partly down, and I can scroll up (or gg) to the top of b and see the diff.

I guess it make sense: by default the active window is for a, and it is showing the top of a; but it forces me to click on b and scroll every time to make sure that I am not missing diffs. And I have forgotten a few times...

Am I the only one to see that? If not, would it be possible to have vim automatically scroll to show the top of the first diff block, regardless of which window it is in?

I am using gvim 7.3.646, on Windows XP. I have diffopt=filler. I have tried other settings, including horizontal diffing, but none helped for that particular issue.

I searched around, but no success, sorry.

Thank you.

No comments: