4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When diff'ing three files the third one isn't displayed correctly.
13 Solution: Compute the size of diff blocks correctly when merging blocks.
14 Compute filler lines correctly when scrolling.
18 *** ../vim-7.1.233/src/diff.c Fri Oct 19 18:57:33 2007
19 --- src/diff.c Fri Jan 18 17:32:31 2008
24 /* second overlap of new block with existing block */
25 ! dp->df_count[idx_new] += count_new - count_orig;
27 /* Adjust the size of the block to include all the lines to the
28 * end of the existing block or the new diff, whatever ends last. */
32 /* second overlap of new block with existing block */
33 ! dp->df_count[idx_new] += count_new - count_orig
34 ! + dpl->df_lnum[idx_orig] + dpl->df_count[idx_orig]
35 ! - (dp->df_lnum[idx_orig] + dp->df_count[idx_orig]);
37 /* Adjust the size of the block to include all the lines to the
38 * end of the existing block or the new diff, whatever ends last. */
44 ! buf_T *buf = fromwin->w_buffer;
45 linenr_T lnum = fromwin->w_topline;
50 ! idx = diff_buf_idx(buf);
51 ! if (idx == DB_COUNT)
52 return; /* safety check */
54 if (curtab->tp_diff_invalid)
59 ! buf_T *frombuf = fromwin->w_buffer;
60 linenr_T lnum = fromwin->w_topline;
67 ! fromidx = diff_buf_idx(frombuf);
68 ! if (fromidx == DB_COUNT)
69 return; /* safety check */
71 if (curtab->tp_diff_invalid)
75 /* search for a change that includes "lnum" in the list of diffblocks. */
76 for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
77 ! if (lnum <= dp->df_lnum[idx] + dp->df_count[idx])
81 /* After last change, compute topline relative to end of file; no
83 towin->w_topline = towin->w_buffer->b_ml.ml_line_count
84 ! - (buf->b_ml.ml_line_count - lnum);
88 /* Find index for "towin". */
89 ! i = diff_buf_idx(towin->w_buffer);
91 return; /* safety check */
93 ! towin->w_topline = lnum + (dp->df_lnum[i] - dp->df_lnum[idx]);
94 ! if (lnum >= dp->df_lnum[idx])
96 ! /* Inside a change: compute filler lines. */
97 ! if (dp->df_count[i] == dp->df_count[idx])
98 towin->w_topfill = fromwin->w_topfill;
99 ! else if (dp->df_count[i] > dp->df_count[idx])
101 ! if (lnum == dp->df_lnum[idx] + dp->df_count[idx])
102 ! towin->w_topline = dp->df_lnum[i] + dp->df_count[i]
103 ! - fromwin->w_topfill;
107 ! if (towin->w_topline >= dp->df_lnum[i] + dp->df_count[i])
109 ! if (diff_flags & DIFF_FILLER)
110 ! towin->w_topfill = dp->df_lnum[idx]
111 ! + dp->df_count[idx] - lnum;
112 ! towin->w_topline = dp->df_lnum[i] + dp->df_count[i];
118 /* search for a change that includes "lnum" in the list of diffblocks. */
119 for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
120 ! if (lnum <= dp->df_lnum[fromidx] + dp->df_count[fromidx])
124 /* After last change, compute topline relative to end of file; no
126 towin->w_topline = towin->w_buffer->b_ml.ml_line_count
127 ! - (frombuf->b_ml.ml_line_count - lnum);
131 /* Find index for "towin". */
132 ! toidx = diff_buf_idx(towin->w_buffer);
133 ! if (toidx == DB_COUNT)
134 return; /* safety check */
136 ! towin->w_topline = lnum + (dp->df_lnum[toidx] - dp->df_lnum[fromidx]);
137 ! if (lnum >= dp->df_lnum[fromidx])
139 ! /* Inside a change: compute filler lines. With three or more
140 ! * buffers we need to know the largest count. */
142 ! for (i = 0; i < DB_COUNT; ++i)
143 ! if (curtab->tp_diffbuf[i] != NULL
144 ! && max_count < dp->df_count[i])
145 ! max_count = dp->df_count[i];
147 ! if (dp->df_count[toidx] == dp->df_count[fromidx])
149 ! /* same number of lines: use same filler count */
150 towin->w_topfill = fromwin->w_topfill;
152 ! else if (dp->df_count[toidx] > dp->df_count[fromidx])
154 ! if (lnum == dp->df_lnum[fromidx] + dp->df_count[fromidx])
156 ! /* more lines in towin and fromwin doesn't show diff
157 ! * lines, only filler lines */
158 ! if (max_count - fromwin->w_topfill >= dp->df_count[toidx])
160 ! /* towin also only shows filler lines */
161 ! towin->w_topline = dp->df_lnum[toidx]
162 ! + dp->df_count[toidx];
163 ! towin->w_topfill = fromwin->w_topfill;
166 ! /* towin still has some diff lines to show */
167 ! towin->w_topline = dp->df_lnum[toidx]
168 ! + max_count - fromwin->w_topfill;
171 ! else if (towin->w_topline >= dp->df_lnum[toidx]
172 ! + dp->df_count[toidx])
174 ! /* less lines in towin and no diff lines to show: compute
176 ! towin->w_topline = dp->df_lnum[toidx] + dp->df_count[toidx];
177 ! if (diff_flags & DIFF_FILLER)
179 ! if (lnum == dp->df_lnum[fromidx] + dp->df_count[fromidx])
180 ! /* fromwin is also out of diff lines */
181 ! towin->w_topfill = fromwin->w_topfill;
183 ! /* fromwin has some diff lines */
184 ! towin->w_topfill = dp->df_lnum[fromidx]
185 ! + max_count - lnum;
189 *** ../vim-7.1.233/src/version.c Fri Jan 18 13:15:32 2008
190 --- src/version.c Fri Jan 18 17:37:32 2008
194 { /* Add new patch number below this line */
200 ERIC IDLE PLAYED: THE DEAD COLLECTOR, MR BINT (A VILLAGE NE'ER-DO -WELL VERY
201 KEEN ON BURNING WITCHES), SIR ROBIN, THE GUARD WHO DOESN'T
202 HICOUGH BUT TRIES TO GET THINGS STRAIGHT, CONCORDE (SIR
203 LAUNCELOT'S TRUSTY STEED), ROGER THE SHRUBBER (A SHRUBBER),
205 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
207 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
208 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
209 \\\ download, build and distribute -- http://www.A-A-P.org ///
210 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///