Repository navigation
Commit 7699e36
committed
fix(tools): close a dirty diff tab before unlinking, and stop saveChanges reading fields a reset clears
This answers the live review rows on head 2fa500a (main 73931fe is its parent; this commit adds no merge, so no new main was merged here).
discardFileTab() matched only TabInputText tabs. A rollback of a new file whose plain tab was already closed therefore unlinked the file under a still open, still dirty TabInputTextDiff: TabInputTextDiff is not a TabInputText, and closeAllDiffViews() skips dirty tabs, so nothing in the rollback could reach it. Measured against this head before the change: fs.unlink called once with the target, vscode.window.tabGroups.close called zero times. The filter now also matches a composite diff tab whose modified uri is the target, so the buffer is restored and saved and the tab closed before the unlink, and a refused close keeps the file instead of deleting under the tab.
saveChanges() captured editedContent up front but then read this.newContent, this.relPath and this.preDiagnostics after awaiting provider state twice, the tab closes and the diagnostics window. reset() lands inside those awaits from Task.ts (it resets the provider at the top of every new API attempt) and from this tool own teardown paths. Interleaving reset() into the state await threw Cannot read properties of undefined (reading the includes method) with document.save() already called once and the commit point already passed, so a write the user approved was reported as a failure; getNewDiagnostics then compared against the empty list reset() installs, which makes every current problem look new. Those three fields are now captured with editedContent. Same interleaving after the change: still lands mid-save, still clears the fields, and the call returns the saved content instead of throwing.
Test-only rows answered in the same commit: the success path now observes writeCommitted inside closeAllDiffViews and asserts onCommit precedes it; the two real restores assert the target uri and the positionAt offsets that make the range full-buffer (content alone passes on a misdirected or partial restore, and the Range double cannot express the extent, so the assertion goes through the offsets the impl actually hands it); the editorless rollback gains the occupied-directory case (retained non-empty file inside the created dir, rmdir rejecting ENOTEMPTY, which removeCreatedDir tolerates only for ENOENT) and the stat-cannot-answer case (skip the unlink, still clean the dirs this edit created). clearTaskState() is now identity-checked like the teardown release beside it, so the guarantee does not rest on instanceId being unique per Task object.
The tab double gained modified.scheme because the implementation guard reads modified.scheme; the double was the only thing that did not carry it.
Gates run on this tree before commit: vitest over DiffViewProvider.spec, writeToFileTool.spec and writeToFileTool-partial-state-cleanup.spec - 176 passed, 5 skipped (181); tsc --noEmit exit 0; and the package lint script (eslint . --ext=ts --max-warnings=0 --cache ...) exit 0 with the eslint cache deleted first, because per-file eslint over an explicit file list is a quick check and is not the gate.
Co-Authored-Changed-By: bseries-merge (review-row answers, controls and measurements for PR #1931).1 parent 2fa500a commit 7699e36
3 files changed
Lines changed: 216 additions & 12 deletions
File tree
- src
- core/tools
- integrations/editor
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
129 | 140 | | |
130 | 141 | | |
131 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
391 | 405 | | |
392 | 406 | | |
393 | 407 | | |
| |||
471 | 485 | | |
472 | 486 | | |
473 | 487 | | |
474 | | - | |
| 488 | + | |
475 | 489 | | |
476 | 490 | | |
477 | 491 | | |
| |||
486 | 500 | | |
487 | 501 | | |
488 | 502 | | |
489 | | - | |
| 503 | + | |
490 | 504 | | |
491 | 505 | | |
492 | 506 | | |
493 | 507 | | |
494 | 508 | | |
495 | | - | |
| 509 | + | |
496 | 510 | | |
497 | 511 | | |
498 | 512 | | |
499 | 513 | | |
500 | | - | |
| 514 | + | |
501 | 515 | | |
502 | 516 | | |
503 | 517 | | |
| |||
1022 | 1036 | | |
1023 | 1037 | | |
1024 | 1038 | | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
1031 | 1055 | | |
1032 | 1056 | | |
1033 | 1057 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
1047 | 1047 | | |
1048 | 1048 | | |
1049 | 1049 | | |
1050 | | - | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
1051 | 1054 | | |
1052 | 1055 | | |
1053 | 1056 | | |
| |||
1056 | 1059 | | |
1057 | 1060 | | |
1058 | 1061 | | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1059 | 1067 | | |
1060 | 1068 | | |
1061 | 1069 | | |
| |||
1755 | 1763 | | |
1756 | 1764 | | |
1757 | 1765 | | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
1758 | 1774 | | |
1759 | 1775 | | |
1760 | 1776 | | |
1761 | 1777 | | |
1762 | 1778 | | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
1763 | 1928 | | |
1764 | 1929 | | |
1765 | 1930 | | |
| |||
1974 | 2139 | | |
1975 | 2140 | | |
1976 | 2141 | | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
1977 | 2146 | | |
1978 | 2147 | | |
1979 | 2148 | | |
| |||
0 commit comments