Fix folder refresh debouncing

This commit is contained in:
Quinten Kock 2025-11-30 01:55:57 +01:00
parent f0520ebbdc
commit 4326199454
2 changed files with 7 additions and 2 deletions

View File

@ -6,6 +6,6 @@ Its primary goal is to provide the user with a stack/column-based navigation his
## Features ## Features
- [x] Basic file editing - [x] Basic file editing
- [x] Terminal integration - [x] Terminal integration
- [x] File watching (note: slow!) - [x] File watching
- [ ] Warn on exit when there are unsaved files - [ ] Warn on exit when there are unsaved files
- [ ] LSP support - [ ] LSP support

View File

@ -15,7 +15,9 @@ async function openFolder() {
} }
// Refresh the current folder tree from main (re-open) // Refresh the current folder tree from main (re-open)
let refreshScheduled = false;
async function refreshFolder() { async function refreshFolder() {
refreshScheduled = false;
const folderTree = await window.electronAPI.getWorkspaceTree().catch(alert); const folderTree = await window.electronAPI.getWorkspaceTree().catch(alert);
if (!folderTree) return; if (!folderTree) return;
folderTreeState.val = folderTree; folderTreeState.val = folderTree;
@ -36,7 +38,10 @@ window.electronAPI.onFsEvent(async (ev: { event: string; path: string }) => {
ev.event === "unlink" ev.event === "unlink"
) { ) {
// Debounce-ish: schedule a refresh // 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 // If a file changed on disk and it's open, show disk version panels