Commit 6a7850b
committed
fix(remediation): fix parseDiffHunks No-newline handler [IDE-2052]
Track lastWasInsertion on diffState to reliably detect whether the
immediately preceding diff line was a '+' insertion when the
'\ No newline at end of file' marker appears.
The old code unconditionally decremented currentLine, which was wrong
for insertions (applyInsertion never advances the cursor). A first fix
attempt used Range.Start.Line == s.currentLine as a proxy but that has
a false-positive in multi-hunk diffs where a later hunk header resets
currentLine to a value coincidentally matching a prior insertion line.
With lastWasInsertion: if the preceding line was '+', strip the
synthetic trailing '\n' from the last TextEdit. If '-', compensate
with currentLine-- as before. Reset the flag on every non-insertion
diff line (hunk header, deletion, context).1 parent b5235ba commit 6a7850b
1 file changed
Lines changed: 20 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
294 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| |||
302 | 303 | | |
303 | 304 | | |
304 | 305 | | |
| 306 | + | |
305 | 307 | | |
306 | 308 | | |
307 | 309 | | |
| |||
313 | 315 | | |
314 | 316 | | |
315 | 317 | | |
| 318 | + | |
316 | 319 | | |
317 | 320 | | |
318 | 321 | | |
| |||
321 | 324 | | |
322 | 325 | | |
323 | 326 | | |
| 327 | + | |
324 | 328 | | |
325 | 329 | | |
326 | 330 | | |
| |||
344 | 348 | | |
345 | 349 | | |
346 | 350 | | |
| 351 | + | |
347 | 352 | | |
348 | 353 | | |
349 | 354 | | |
| |||
359 | 364 | | |
360 | 365 | | |
361 | 366 | | |
362 | | - | |
363 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
364 | 379 | | |
365 | 380 | | |
366 | 381 | | |
367 | 382 | | |
368 | 383 | | |
| 384 | + | |
369 | 385 | | |
370 | 386 | | |
371 | 387 | | |
| |||
0 commit comments