feat: add ability to create file#242
Conversation
Codecov Report
@@ Coverage Diff @@
## main #242 +/- ##
==========================================
+ Coverage 75.27% 84.66% +9.39%
==========================================
Files 103 12 -91
Lines 5370 652 -4718
Branches 451 0 -451
==========================================
- Hits 4042 552 -3490
+ Misses 1313 100 -1213
+ Partials 15 0 -15 see 90 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
cguedes
left a comment
There was a problem hiding this comment.
Generally great PR.
Added some note about the atoms complexity (collapsed) and other minor comments.
| collapsedAtom: atom( | ||
| (get) => get(collapsedAtom), | ||
| (get, set) => set(collapsedAtom, !get(collapsedAtom)), | ||
| ), |
There was a problem hiding this comment.
I think we should make this a primitive atom and split the toggle (that currently is implemented in the writable part) to a new atom action.
Or instead keep only the primitive atom and update usages to be explicit in the action:
const [collapsed, setCollapsed] = useAtom(fileExplorerEntry.collapsedAtom);
...
onClick={() => toggleCollapsed(!collapsed)}| } | ||
|
|
||
| async function isValidName(name: string, openEditorNames: string[]) { | ||
| return !openEditorNames.includes(name) && !(await exists(`${await getBaseDir()}/${name}`)); |
There was a problem hiding this comment.
I don't like this dependency of tauri (and filesystem) here.
For the exists, I think that should be fine to trust that the store is in sync with the filesystem (then we can implement a fs watcher to make sure that the file explorer is in sync).
For the base dir, if needed, we should get is as parameter (or stored in a core atom, and updated on load)
This adds the shortcut Cmd+N to create a new file (and the corresponding item in the menu)
This also refactors the file tree component to use an atom. This enables several things:
This will also make the creation of delete and rename features easier
Closes #209