Commit c887249
authored
Clean Up File Management (#1969)
### Description
#### App changes:
- Creating a new file always selects it in the project navigator and selects or opens it in a tab.
- Creating a new folder always selects it.
- Renaming a file always selects it.
- Renaming a file no longer sometimes adds a trailing period to the file name.
- File system updates no longer clear the project navigator's selection.
- No longer attempts to save folders and files whose name was not changed when the name field is submitted.
- Fixes a case where the navigator filter was empty but files were still being filtered.
#### Code changes:
- Cleans up the file management API for the `CEWorkspaceFileManager`.
- Each method now throws, and if it creates a file or folder it returns it.
- Errors are logged by the file manager's own logger before being thrown, for better debugging output and standardization across the code base.
- Introduced a `FileManagerError` enum that has meaningful error description and resolution messages. This type is now used in the file management methods where it makes sense. The type is suitable for presenting in an `NSAlert`.
- Standardizes up how the workspace is notified of new/moved/copied files. Changes include the project navigator and file inspector.
- Always notifies the project navigator and other listeners using the `workspace.listenerModel`, as well as opening a tab if it's not a folder.
- If file errors are thrown, presents an `NSAlert` with the error information.
- Removed a `DispatchQueue.async` call in the project navigator that caused a new selection received by the project navigator to be overwritten, causing a flashing selection when new files were created and subsequently selected, which also resulted in incorrect selections.
- Moved `String.isValidFilename` to its own file, and added checks for more invalid cases.
- Added a flag to the `DirectoryEventStream` to receive more timely notifications.
- Added a check to see if the project navigator filter is empty before displaying filtered files.
#### Tests:
- Added UI tests to the project navigator.
- Added unit tests for the `isValidFilename` extension.
- Added a UI testing document.
- Uncommented the directory changes listener test after adding the new flag to the directory event stream.
### Related Issues
- Closes #1934
- Closes #1966
### 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
<details><summary>On main</summary>
<p>
https://github.com/user-attachments/assets/f2404f06-aa59-4486-95c2-8cf9432254b2
https://github.com/user-attachments/assets/af365adf-0704-475f-bd1e-347f66855114
</p>
</details>
https://github.com/user-attachments/assets/4c3b7a3b-3c30-45fa-b7f3-6e428c10641e
https://github.com/user-attachments/assets/02967b41-409c-4bbc-bd86-0d12469852d61 parent 6d16c90 commit c887249
File tree
23 files changed
+721
-251
lines changed- CodeEdit.xcodeproj
- CodeEditTests/Utils
- CEWorkspaceFileManager
- CodeEditUITests
- Features
- ActivityViewer/Tasks
- CodeEdit
- Features
- CEWorkspace/Models
- InspectorArea/FileInspector
- Utils/Extensions/String
23 files changed
+721
-251
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| 483 | + | |
| 484 | + | |
483 | 485 | | |
484 | 486 | | |
485 | 487 | | |
| |||
488 | 490 | | |
489 | 491 | | |
490 | 492 | | |
| 493 | + | |
| 494 | + | |
491 | 495 | | |
492 | 496 | | |
493 | 497 | | |
| |||
1161 | 1165 | | |
1162 | 1166 | | |
1163 | 1167 | | |
| 1168 | + | |
| 1169 | + | |
1164 | 1170 | | |
1165 | 1171 | | |
1166 | 1172 | | |
1167 | 1173 | | |
1168 | 1174 | | |
1169 | 1175 | | |
1170 | 1176 | | |
| 1177 | + | |
| 1178 | + | |
1171 | 1179 | | |
1172 | 1180 | | |
1173 | 1181 | | |
| |||
2425 | 2433 | | |
2426 | 2434 | | |
2427 | 2435 | | |
| 2436 | + | |
2428 | 2437 | | |
2429 | 2438 | | |
2430 | 2439 | | |
| |||
2502 | 2511 | | |
2503 | 2512 | | |
2504 | 2513 | | |
2505 | | - | |
2506 | 2514 | | |
| 2515 | + | |
2507 | 2516 | | |
2508 | 2517 | | |
2509 | 2518 | | |
2510 | 2519 | | |
2511 | 2520 | | |
2512 | | - | |
2513 | | - | |
2514 | 2521 | | |
2515 | 2522 | | |
2516 | 2523 | | |
| 2524 | + | |
| 2525 | + | |
2517 | 2526 | | |
2518 | 2527 | | |
2519 | 2528 | | |
| |||
2532 | 2541 | | |
2533 | 2542 | | |
2534 | 2543 | | |
| 2544 | + | |
2535 | 2545 | | |
2536 | 2546 | | |
2537 | 2547 | | |
| |||
3031 | 3041 | | |
3032 | 3042 | | |
3033 | 3043 | | |
| 3044 | + | |
3034 | 3045 | | |
3035 | 3046 | | |
3036 | 3047 | | |
| |||
3056 | 3067 | | |
3057 | 3068 | | |
3058 | 3069 | | |
| 3070 | + | |
3059 | 3071 | | |
3060 | 3072 | | |
3061 | 3073 | | |
| |||
3977 | 3989 | | |
3978 | 3990 | | |
3979 | 3991 | | |
| 3992 | + | |
3980 | 3993 | | |
3981 | 3994 | | |
3982 | 3995 | | |
| |||
4073 | 4086 | | |
4074 | 4087 | | |
4075 | 4088 | | |
| 4089 | + | |
4076 | 4090 | | |
4077 | 4091 | | |
4078 | 4092 | | |
| |||
4136 | 4150 | | |
4137 | 4151 | | |
4138 | 4152 | | |
| 4153 | + | |
4139 | 4154 | | |
4140 | 4155 | | |
4141 | 4156 | | |
| |||
4632 | 4647 | | |
4633 | 4648 | | |
4634 | 4649 | | |
| 4650 | + | |
4635 | 4651 | | |
4636 | 4652 | | |
4637 | 4653 | | |
| |||
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
257 | | - | |
258 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
259 | 260 | | |
260 | 261 | | |
261 | | - | |
262 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
263 | 265 | | |
264 | 266 | | |
265 | 267 | | |
| |||
Lines changed: 10 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
44 | 40 | | |
| 41 | + | |
45 | 42 | | |
46 | 43 | | |
47 | 44 | | |
| |||
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
0 commit comments