]>
Commit | Line | Data |
---|---|---|
d57b4abe ER |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.1.234 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.1.234 | |
11 | Problem: When diff'ing three files the third one isn't displayed correctly. | |
12 | (Gary Johnson) | |
13 | Solution: Compute the size of diff blocks correctly when merging blocks. | |
14 | Compute filler lines correctly when scrolling. | |
15 | Files: src/diff.c | |
16 | ||
17 | ||
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 | |
20 | *************** | |
21 | *** 1299,1305 **** | |
22 | } | |
23 | else | |
24 | /* second overlap of new block with existing block */ | |
25 | ! dp->df_count[idx_new] += count_new - count_orig; | |
26 | ||
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. */ | |
29 | --- 1299,1307 ---- | |
30 | } | |
31 | else | |
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]); | |
36 | ||
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. */ | |
39 | *************** | |
40 | *** 1628,1641 **** | |
41 | win_T *fromwin; | |
42 | win_T *towin; | |
43 | { | |
44 | ! buf_T *buf = fromwin->w_buffer; | |
45 | linenr_T lnum = fromwin->w_topline; | |
46 | ! int idx; | |
47 | diff_T *dp; | |
48 | int i; | |
49 | ||
50 | ! idx = diff_buf_idx(buf); | |
51 | ! if (idx == DB_COUNT) | |
52 | return; /* safety check */ | |
53 | ||
54 | if (curtab->tp_diff_invalid) | |
55 | --- 1630,1645 ---- | |
56 | win_T *fromwin; | |
57 | win_T *towin; | |
58 | { | |
59 | ! buf_T *frombuf = fromwin->w_buffer; | |
60 | linenr_T lnum = fromwin->w_topline; | |
61 | ! int fromidx; | |
62 | ! int toidx; | |
63 | diff_T *dp; | |
64 | + int max_count; | |
65 | int i; | |
66 | ||
67 | ! fromidx = diff_buf_idx(frombuf); | |
68 | ! if (fromidx == DB_COUNT) | |
69 | return; /* safety check */ | |
70 | ||
71 | if (curtab->tp_diff_invalid) | |
72 | *************** | |
73 | *** 1645,1686 **** | |
74 | ||
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]) | |
78 | break; | |
79 | if (dp == NULL) | |
80 | { | |
81 | /* After last change, compute topline relative to end of file; no | |
82 | * filler lines. */ | |
83 | towin->w_topline = towin->w_buffer->b_ml.ml_line_count | |
84 | ! - (buf->b_ml.ml_line_count - lnum); | |
85 | } | |
86 | else | |
87 | { | |
88 | /* Find index for "towin". */ | |
89 | ! i = diff_buf_idx(towin->w_buffer); | |
90 | ! if (i == DB_COUNT) | |
91 | return; /* safety check */ | |
92 | ||
93 | ! towin->w_topline = lnum + (dp->df_lnum[i] - dp->df_lnum[idx]); | |
94 | ! if (lnum >= dp->df_lnum[idx]) | |
95 | { | |
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]) | |
100 | { | |
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; | |
104 | } | |
105 | ! else | |
106 | { | |
107 | ! if (towin->w_topline >= dp->df_lnum[i] + dp->df_count[i]) | |
108 | { | |
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]; | |
113 | } | |
114 | } | |
115 | } | |
116 | --- 1649,1720 ---- | |
117 | ||
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]) | |
121 | break; | |
122 | if (dp == NULL) | |
123 | { | |
124 | /* After last change, compute topline relative to end of file; no | |
125 | * filler lines. */ | |
126 | towin->w_topline = towin->w_buffer->b_ml.ml_line_count | |
127 | ! - (frombuf->b_ml.ml_line_count - lnum); | |
128 | } | |
129 | else | |
130 | { | |
131 | /* Find index for "towin". */ | |
132 | ! toidx = diff_buf_idx(towin->w_buffer); | |
133 | ! if (toidx == DB_COUNT) | |
134 | return; /* safety check */ | |
135 | ||
136 | ! towin->w_topline = lnum + (dp->df_lnum[toidx] - dp->df_lnum[fromidx]); | |
137 | ! if (lnum >= dp->df_lnum[fromidx]) | |
138 | { | |
139 | ! /* Inside a change: compute filler lines. With three or more | |
140 | ! * buffers we need to know the largest count. */ | |
141 | ! max_count = 0; | |
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]; | |
146 | ! | |
147 | ! if (dp->df_count[toidx] == dp->df_count[fromidx]) | |
148 | ! { | |
149 | ! /* same number of lines: use same filler count */ | |
150 | towin->w_topfill = fromwin->w_topfill; | |
151 | ! } | |
152 | ! else if (dp->df_count[toidx] > dp->df_count[fromidx]) | |
153 | { | |
154 | ! if (lnum == dp->df_lnum[fromidx] + dp->df_count[fromidx]) | |
155 | ! { | |
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]) | |
159 | ! { | |
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; | |
164 | ! } | |
165 | ! else | |
166 | ! /* towin still has some diff lines to show */ | |
167 | ! towin->w_topline = dp->df_lnum[toidx] | |
168 | ! + max_count - fromwin->w_topfill; | |
169 | ! } | |
170 | } | |
171 | ! else if (towin->w_topline >= dp->df_lnum[toidx] | |
172 | ! + dp->df_count[toidx]) | |
173 | { | |
174 | ! /* less lines in towin and no diff lines to show: compute | |
175 | ! * filler lines */ | |
176 | ! towin->w_topline = dp->df_lnum[toidx] + dp->df_count[toidx]; | |
177 | ! if (diff_flags & DIFF_FILLER) | |
178 | { | |
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; | |
182 | ! else | |
183 | ! /* fromwin has some diff lines */ | |
184 | ! towin->w_topfill = dp->df_lnum[fromidx] | |
185 | ! + max_count - lnum; | |
186 | } | |
187 | } | |
188 | } | |
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 | |
191 | *************** | |
192 | *** 668,669 **** | |
193 | --- 668,671 ---- | |
194 | { /* Add new patch number below this line */ | |
195 | + /**/ | |
196 | + 234, | |
197 | /**/ | |
198 | ||
199 | -- | |
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), | |
204 | BROTHER MAYNARD | |
205 | "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD | |
206 | ||
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 /// |