Skip to content

fs: Map EventKind::Other to Changed instead of None#48695

Closed
lex00 wants to merge 2 commits intozed-industries:mainfrom
lex00:fix/eventkind-other-mapping
Closed

fs: Map EventKind::Other to Changed instead of None#48695
lex00 wants to merge 2 commits intozed-industries:mainfrom
lex00:fix/eventkind-other-mapping

Conversation

@lex00
Copy link
Copy Markdown
Contributor

@lex00 lex00 commented Feb 7, 2026

Closes #48694
Related to #38109

Problem

When the OS event queue overflows, the notify crate emits EventKind::Other as a rescan signal (e.g. macOS MustScanSubDirs, Linux IN_Q_OVERFLOW). The catch-all in fs_watcher.rs maps this to None.

Three downstream consumers silently drop events with kind: None:

  • BackgroundScanner initial scan filters them out (worktree.rs)
  • Settings file watcher ignores them (settings_file.rs)
  • LSP didChangeWatchedFiles notifications skip them (lsp_store.rs)

The original _ => None predates these consumers. When it was written, process_events() stripped the kind and only used paths, so None was harmless. The settings watcher and LSP path were added later and assumed kind would always be set.

This is an uncommon trigger (requires event queue overflow from heavy filesystem activity) and the failure is silent, which makes it hard to link to specific user reports. But the fix is simple and the current behavior is clearly wrong.

Fix

Map the catch-all to Some(PathEventKind::Changed). "Something changed, re-read from disk" is the correct semantic for both EventKind::Other and EventKind::Any.

Extracted the mapping into a standalone path_event_kind() function with unit tests.

Release Notes:

  • Fixed an issue where filesystem events could be silently dropped after OS event queue overflow, potentially causing stale settings and missing LSP notifications.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 7, 2026
@marcocondrache
Copy link
Copy Markdown
Contributor

Just a small thought: since EventKind has other variants like EventKind::Access that wouldn’t really fit under Changed, maybe it would be safer to only map EventKind::Other for now?

Ref: https://docs.rs/notify/latest/notify/enum.EventKind.html

@lex00
Copy link
Copy Markdown
Contributor Author

lex00 commented Feb 8, 2026

Thanks @marcocondrache , I'm new here I appreciate it. This makes it more defensive.

It looks like handle_event function filters out Access events at line 247-252 before callback , so events never reach path_event_kind() in practice.

lex00 and others added 2 commits February 13, 2026 12:00
The catch-all arm in the EventKind → PathEventKind mapping returned
None for EventKind::Other and EventKind::Any. Three downstream
consumers drop events with kind: None:

- BackgroundScanner initial scan filters them out
- Settings file watcher silently ignores them
- LSP didChangeWatchedFiles notifications are never sent

EventKind::Other includes OS rescan signals like macOS
MustScanSubDirs (FSEvents queue overflow). Map these to Changed
so all consumers handle them correctly.

Extracts the mapping into a standalone function for testability.

Related to zed-industries#38109

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Only map EventKind::Other and EventKind::Any to Changed, keeping
Access (and any future unknown variants) as None.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lex00 lex00 force-pushed the fix/eventkind-other-mapping branch from 3234eff to e726657 Compare February 13, 2026 19:01
pcfreak30 added a commit to pcfreak30/zed that referenced this pull request Feb 13, 2026
Applied 5 PRs to fix Zed getting out of sync with filesystem changes:
- zed-industries#48691: Include file size in DiskState to fix stale buffer reload
- zed-industries#48695: Map EventKind::Other to Changed instead of None
- zed-industries#48698: Reload after undo when file changed while dirty
- zed-industries#48704: Rescan repositories when window regains focus
- zed-industries#47462: Handle removed Linux watch paths
@lex00 lex00 closed this Mar 1, 2026
@lex00 lex00 deleted the fix/eventkind-other-mapping branch March 1, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs: EventKind::Other and EventKind::Any silently dropped by file watcher

2 participants