Buffer file writes, because writing to file after every keypress has bad consequences (#4242)

* Buffer file writes, because writing to file after every keypress does bad things

* fix: kevin -- added timeouts for the time being since the workflow for saving data to disk is now changed

---------

Co-authored-by: Kevin Nadro <kevin@zoo.dev>
This commit is contained in:
49fl
2024-10-21 16:07:20 -04:00
committed by GitHub
parent c42967d0e7
commit d2c6b5cf3a
3 changed files with 22 additions and 3 deletions

View File

@ -488,6 +488,12 @@ export const FileTreeInner = ({
// Refresh the file tree when there are changes.
useFileSystemWatcher(
async (eventType, path) => {
// Our other watcher races with this watcher on the current file changes,
// so we need to stop this one from reacting at all, otherwise Bad Things
// Happen™.
const isCurrentFile = loaderData.file?.path === path
const hasChanged = eventType === 'change'
if (isCurrentFile && hasChanged) return
fileSend({ type: 'Refresh' })
},
[loaderData?.project?.path, fileContext.selectedDirectory.path].filter(