Skip to content

core/reloader: fix file watcher compatibility with vscode #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

karboggy
Copy link
Contributor

Some editors (e.g vscode) can sometimes save files in two steps: truncate + write.
This causes QFileSystemWatcher to emit the fileChanged signal twice.

It can be visualized with:
inotifywait -m -e modify,create,delete,delete_self,close_write path/to/my-file.qml

On the first event (truncate), the file size is zero. If quickshell reloads the configuration at this point, it may result to a Reloading configuration error.

This initial event can be safely ignored. The second event (when the file is written) will correctly trigger a reload with valid content.

@outfoxxed
Copy link
Member

Looks good, but could it reasonably end up writing in multiple steps?

@karboggy
Copy link
Contributor Author

This behavior seems related to all Node.js / Electron apps (including vscode and codium) . For example, VSCode’s save process is discussed in this issue:
microsoft/vscode#63720

@karboggy karboggy force-pushed the fix/file-watcher-ignore-truncate-file branch from 5a39e44 to 6cfcd31 Compare July 24, 2025 06:49
@karboggy karboggy requested a review from outfoxxed July 24, 2025 06:58
Copy link
Member

@outfoxxed outfoxxed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise lgtm

@karboggy karboggy force-pushed the fix/file-watcher-ignore-truncate-file branch from 6cfcd31 to 4091407 Compare July 24, 2025 08:42
@outfoxxed outfoxxed force-pushed the fix/file-watcher-ignore-truncate-file branch from 4091407 to 3bbf39c Compare July 24, 2025 22:44
@outfoxxed outfoxxed merged commit 3bbf39c into quickshell-mirror:master Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants