Fix folder refresh debouncing
This commit is contained in:
parent
f0520ebbdc
commit
4326199454
|
|
@ -6,6 +6,6 @@ Its primary goal is to provide the user with a stack/column-based navigation his
|
|||
## Features
|
||||
- [x] Basic file editing
|
||||
- [x] Terminal integration
|
||||
- [x] File watching (note: slow!)
|
||||
- [x] File watching
|
||||
- [ ] Warn on exit when there are unsaved files
|
||||
- [ ] LSP support
|
||||
|
|
@ -15,7 +15,9 @@ async function openFolder() {
|
|||
}
|
||||
|
||||
// Refresh the current folder tree from main (re-open)
|
||||
let refreshScheduled = false;
|
||||
async function refreshFolder() {
|
||||
refreshScheduled = false;
|
||||
const folderTree = await window.electronAPI.getWorkspaceTree().catch(alert);
|
||||
if (!folderTree) return;
|
||||
folderTreeState.val = folderTree;
|
||||
|
|
@ -36,7 +38,10 @@ window.electronAPI.onFsEvent(async (ev: { event: string; path: string }) => {
|
|||
ev.event === "unlink"
|
||||
) {
|
||||
// Debounce-ish: schedule a refresh
|
||||
setTimeout(() => refreshFolder(), 50);
|
||||
if(!refreshScheduled) {
|
||||
refreshScheduled = true;
|
||||
setTimeout(() => refreshFolder(), 50);
|
||||
}
|
||||
}
|
||||
|
||||
// If a file changed on disk and it's open, show disk version panels
|
||||
|
|
|
|||
Loading…
Reference in New Issue