Repository navigation
Commit 9c54765
easonLiangWorldedtech
fix(editor): fail closed when a rollback restore or save is refused
The pre-merge table still reported the Persistence Integrity error at the previous head. The last
round fixed one call site - the new-file rollback - but the defect class has a second call site: the
existing-file branch of revertChanges() built its own WorkspaceEdit, discarded the boolean result of
workspace.applyEdit(), and saved unconditionally, so a refused restore wrote unapproved streamed
content into an existing file. Fixing one call site is not fixing the defect class.
The branch now runs through the same callee-owned contract as the new-file rollback instead of adding
a third inline copy of the check: restorePreStreamBuffer() throws when the editor refuses the restore,
so the save that follows cannot run, and saveBufferClean() now treats a save that did not happen as a
failure rather than a success. Both methods accept the document explicitly, because this branch
reached it through activeDiffEditor; resolving it again by path could pick a different buffer or none,
and none would skip the restore in silence. One test leaves the path lookup empty on purpose so that
assumption is pinned rather than assumed.
Same-class call sites in the same file that this change deliberately does not sweep, registered here
rather than changed: the save in showEditedFileWithoutDisruptingFocus, the three applyEdit calls in
saveChanges and its append path, the save in saveChanges, and the save in keepOrCloseEditedFile. None
is on the rollback path this unit changed; each needs its own row or issue.
Nine test fixtures mocked TextDocument.save() as resolving undefined; the API resolves a boolean, so
they now resolve true - the new failure check would otherwise be reading a fixture inaccuracy.
Verified: integrations/editor 95 passed (three new tests: real restore-and-save for an existing file,
no save on a refused restore, failure on a save that did not happen), core/tools 669, core/task 829;
eslint . --ext=ts --max-warnings=0 exit 0 with no suppression count increase; tsc --noEmit 0 errors;
prettier --check . reports 0 offenders in a worktree checked out with core.autocrlf=false. Negative
controls, each restored byte-for-byte: dropping the refused-restore check turns exactly the two
refused-restore tests red (the contract now guards both branches); dropping the failed-save check
turns exactly its own test red; resolving the existing-file document by path again turns three tests
red, which is the evidence that passing the document explicitly is load-bearing.1 parent e41ebe0 commit 9c54765
2 files changed
Lines changed: 153 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
614 | 609 | | |
615 | | - | |
616 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
617 | 616 | | |
618 | 617 | | |
619 | 618 | | |
| |||
967 | 966 | | |
968 | 967 | | |
969 | 968 | | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
975 | 980 | | |
976 | 981 | | |
977 | 982 | | |
978 | | - | |
979 | | - | |
| 983 | + | |
| 984 | + | |
980 | 985 | | |
981 | 986 | | |
982 | 987 | | |
| |||
995 | 1000 | | |
996 | 1001 | | |
997 | 1002 | | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
1004 | 1017 | | |
1005 | 1018 | | |
1006 | 1019 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
875 | 875 | | |
876 | 876 | | |
877 | 877 | | |
878 | | - | |
| 878 | + | |
879 | 879 | | |
880 | 880 | | |
881 | 881 | | |
| |||
1020 | 1020 | | |
1021 | 1021 | | |
1022 | 1022 | | |
1023 | | - | |
| 1023 | + | |
1024 | 1024 | | |
1025 | 1025 | | |
1026 | 1026 | | |
| |||
1045 | 1045 | | |
1046 | 1046 | | |
1047 | 1047 | | |
1048 | | - | |
| 1048 | + | |
1049 | 1049 | | |
1050 | 1050 | | |
1051 | 1051 | | |
| |||
1065 | 1065 | | |
1066 | 1066 | | |
1067 | 1067 | | |
1068 | | - | |
| 1068 | + | |
1069 | 1069 | | |
1070 | 1070 | | |
1071 | 1071 | | |
| |||
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
1119 | | - | |
| 1119 | + | |
1120 | 1120 | | |
1121 | 1121 | | |
1122 | 1122 | | |
| |||
1140 | 1140 | | |
1141 | 1141 | | |
1142 | 1142 | | |
1143 | | - | |
| 1143 | + | |
1144 | 1144 | | |
1145 | 1145 | | |
1146 | 1146 | | |
| |||
1439 | 1439 | | |
1440 | 1440 | | |
1441 | 1441 | | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
1442 | 1546 | | |
1443 | 1547 | | |
1444 | 1548 | | |
| |||
1620 | 1724 | | |
1621 | 1725 | | |
1622 | 1726 | | |
1623 | | - | |
| 1727 | + | |
1624 | 1728 | | |
1625 | 1729 | | |
1626 | 1730 | | |
| |||
2109 | 2213 | | |
2110 | 2214 | | |
2111 | 2215 | | |
2112 | | - | |
| 2216 | + | |
2113 | 2217 | | |
2114 | 2218 | | |
2115 | 2219 | | |
| |||
0 commit comments