Commit 1820691
committed
fix(diff): correctly classify file type for addition-only modifications
The diff viewer was not showing green background highlighting for added
lines in modified files that only had additions (no deletions), like
`src/constants.js` in svelte 5.16.2→5.50.0.
Root cause:
1. `parseUnifiedDiff` used a heuristic that reclassified files based on
diff content: if a file had only insertions, it was marked as 'add'
(new file). This was wrong for modifications with only additions.
2. `computeDiff` in ViewerPanel used `parsed.type` ('add') instead of
the correctly computed `type` ('modify') based on file existence.
3. DiffLine intentionally skips green background when fileStatus='add'
(all lines in a new file are additions, so highlighting is redundant).
This caused addition-only modifications to lose visual highlighting.
Fix:
- `parseUnifiedDiff`: Replace the content-based heuristic with proper
/dev/null path detection from --- / +++ headers, which is the standard
way unified diffs indicate new/deleted files.
- `ViewerPanel.vue`: Use the file-existence-based type instead of the
parsed diff type.1 parent 930667e commit 1820691
2 files changed
+20
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
123 | 127 | | |
124 | 128 | | |
125 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
191 | 194 | | |
192 | 195 | | |
| 196 | + | |
| 197 | + | |
193 | 198 | | |
194 | 199 | | |
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
198 | | - | |
| 203 | + | |
199 | 204 | | |
200 | 205 | | |
201 | 206 | | |
| |||
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
208 | 219 | | |
209 | | - | |
| 220 | + | |
210 | 221 | | |
211 | | - | |
| 222 | + | |
212 | 223 | | |
213 | 224 | | |
214 | 225 | | |
| 226 | + | |
215 | 227 | | |
216 | 228 | | |
217 | 229 | | |
| |||
279 | 291 | | |
280 | 292 | | |
281 | 293 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | 294 | | |
296 | 295 | | |
297 | 296 | | |
| |||
0 commit comments