Commit 4ce9be0
authored
Editor Restoration (#2078)
### Description
Implements editor restoration, helping ease the user experience for longer editing tasks spanning multiple files. Users expect opened tabs to retain the scroll position, cursors, and undo stack. To facilitate this, we receive a stream of state updates from the editor and save them to a SQLite DB. When a file is opened again, the state is restored from that DB.
Ideally this is transparent to the user. However, there is one very slight UX flaw that this doesn't address: highlighting. When a user restores an editor there can be a flash as the highlighter works to do syntax highlighting on the newly opened editor. Some potential future directions:
- The text storage object that outlives editors does retain color information, if we could avoid wiping that color information when an editor is loaded we could avoid that slight delay.
- To do that, we need to store that state with the storage object somehow. Either through a custom text attribute (could be finicky) or maybe by subclassing NSTextStorage and adding a flag.
> [!NOTE]
> This includes a mechanism for sharing undo stacks for editors during a workspace's lifetime. As @austincondiff mentioned on discord, it should add a undo frame when a file is updated externally. This PR notably does not include that change. I'll be adding it in #2075
### Related Issues
* closes #2057
### Checklist
- [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md)
- [x] The issues this PR addresses are related to each other
- [x] My changes generate no new warnings
- [x] My code builds and runs on my machine
- [x] My changes are all related to the related issue above
- [x] I documented my code
### Screenshots
https://github.com/user-attachments/assets/6a9ff5ea-743e-4183-83c9-b774915b0c351 parent 666d33b commit 4ce9be0
File tree
30 files changed
+685
-192
lines changed- CodeEdit.xcodeproj
- CodeEditTests
- Features/Editor
- Utils
- CodeEdit
- Features
- Documents
- Controllers
- WorkspaceDocument
- Editor
- Models
- EditorLayout
- Editor
- Restoration
- TabBar
- Tabs/Tab
- Views
- Views
- OpenQuickly/Views
- StatusBar/Views/StatusBarItems
- WindowCommands
30 files changed
+685
-192
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
| 175 | + | |
| 176 | + | |
173 | 177 | | |
174 | 178 | | |
175 | 179 | | |
| |||
323 | 327 | | |
324 | 328 | | |
325 | 329 | | |
| 330 | + | |
| 331 | + | |
326 | 332 | | |
327 | 333 | | |
328 | 334 | | |
| |||
425 | 431 | | |
426 | 432 | | |
427 | 433 | | |
428 | | - | |
429 | 434 | | |
430 | 435 | | |
| 436 | + | |
431 | 437 | | |
432 | 438 | | |
433 | 439 | | |
| |||
1755 | 1761 | | |
1756 | 1762 | | |
1757 | 1763 | | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
1758 | 1772 | | |
1759 | 1773 | | |
1760 | 1774 | | |
| |||
1779 | 1793 | | |
1780 | 1794 | | |
1781 | 1795 | | |
1782 | | - | |
1783 | | - | |
1784 | | - | |
1785 | | - | |
1786 | | - | |
1787 | | - | |
1788 | | - | |
1789 | | - | |
1790 | 1796 | | |
1791 | 1797 | | |
1792 | 1798 | | |
| |||
1839 | 1845 | | |
1840 | 1846 | | |
1841 | 1847 | | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
1842 | 1852 | | |
1843 | 1853 | | |
1844 | 1854 | | |
| |||
1862 | 1872 | | |
1863 | 1873 | | |
1864 | 1874 | | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
1865 | 1880 | | |
1866 | 1881 | | |
1867 | 1882 | | |
| |||
Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | | - | |
| 71 | + | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
| 76 | + | |
73 | 77 | | |
74 | | - | |
| 78 | + | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
82 | | - | |
| 86 | + | |
| 87 | + | |
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
| 91 | + | |
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
| |||
135 | 141 | | |
136 | 142 | | |
137 | 143 | | |
138 | | - | |
| 144 | + | |
139 | 145 | | |
140 | 146 | | |
141 | 147 | | |
| |||
165 | 171 | | |
166 | 172 | | |
167 | 173 | | |
168 | | - | |
| 174 | + | |
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
| |||
207 | 213 | | |
208 | 214 | | |
209 | 215 | | |
210 | | - | |
| 216 | + | |
211 | 217 | | |
212 | 218 | | |
213 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | | - | |
24 | | - | |
25 | | - | |
| 21 | + | |
| 22 | + | |
26 | 23 | | |
27 | | - | |
| 24 | + | |
| 25 | + | |
28 | 26 | | |
29 | | - | |
| 27 | + | |
| 28 | + | |
30 | 29 | | |
31 | | - | |
| 30 | + | |
32 | 31 | | |
33 | | - | |
| 32 | + | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
36 | 35 | | |
37 | | - | |
| 36 | + | |
38 | 37 | | |
39 | | - | |
40 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
41 | 111 | | |
42 | 112 | | |
| 113 | + | |
| 114 | + | |
43 | 115 | | |
44 | 116 | | |
45 | 117 | | |
| |||
53 | 125 | | |
54 | 126 | | |
55 | 127 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | 128 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 129 | + | |
65 | 130 | | |
66 | 131 | | |
67 | 132 | | |
68 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
69 | 139 | | |
70 | 140 | | |
71 | 141 | | |
| |||
0 commit comments