Repository navigation
Commit 7752664
easonLiangWorldedtech
fix(diff-view): roll back the created file and dirs when open() fails early
DiffViewProvider.open() creates the parent directories and writes an empty placeholder
BEFORE it awaits openDiffEditor(). If that await rejects there is no activeDiffEditor, and
revertChanges() bailed out on `!this.activeDiffEditor` - leaving the placeholder and the new
directories on disk. The next execute() then saw an empty file and treated the requested new
file as an existing one, so a denial preserved the debris instead of removing it. The
streaming-failure cleanup in handlePartial() calls exactly this rollback, so the debris was
reachable from the new path in this unit.
The filesystem rollback now runs regardless of the editor: only the document work (save the
dirty buffer, close the diff views and the tab) needs one. removeCreatedFile/removeCreatedDir
tolerate ENOENT, since the failed open may never have written the placeholder - that must not
abort the rest of the cleanup.
Tests: 'revertChanges() removes the placeholder and created dirs when open() failed before the
editor existed' (unlink for the relPath, rmdir in reverse order) and 'revertChanges() tolerates
a placeholder that was never written' (ENOENT rejection does not propagate, delete still
attempted). Pin: restoring the old `!this.activeDiffEditor` early return fails both.
Local: integrations/editor + writeToFileTool.spec + core/task + assistant-message = 786 passed
(the single remaining failure, saveChanges default delay, reproduces without these changes);
tsc 0; eslint 0 err / 0 warn on both files.1 parent e0b0e0e commit 7752664
2 files changed
Lines changed: 100 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
| |||
513 | 518 | | |
514 | 519 | | |
515 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
516 | 547 | | |
517 | | - | |
| 548 | + | |
518 | 549 | | |
519 | 550 | | |
520 | 551 | | |
521 | 552 | | |
522 | | - | |
523 | 553 | | |
524 | 554 | | |
525 | 555 | | |
| |||
528 | 558 | | |
529 | 559 | | |
530 | 560 | | |
531 | | - | |
532 | | - | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
533 | 577 | | |
534 | 578 | | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
| 579 | + | |
540 | 580 | | |
541 | 581 | | |
542 | 582 | | |
543 | | - | |
| 583 | + | |
544 | 584 | | |
| 585 | + | |
545 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
546 | 593 | | |
547 | 594 | | |
548 | 595 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
| |||
1165 | 1170 | | |
1166 | 1171 | | |
1167 | 1172 | | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
1168 | 1211 | | |
1169 | 1212 | | |
1170 | 1213 | | |
| |||
0 commit comments