fix(#3178): handle Windows paths in ignore_dirs and add .zig-cache to defaults #3261
+22
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a critical memory leak issue on Windows where
nvim-tree.luaspawns infinite filesystem watchers when the.zig-cache/tmpfolder creates temporary files during a build process. The watcher locks these files, preventing Zig from deleting them and causing memory to grow by 10-20 MB/second.Changes
Added
.zig-cacheto defaultignore_dirs- This directory contains build artifacts not under version control, similar to existing defaults likenode_modulesandbuild.Fixed Windows path handling in
ignore_dirs- The forward slash prefix (e.g.,/node_modules) used in default ignore patterns wasn't matching Windows paths (e.g.,M:\path\to\node_modules). The fix converts forward slashes to backslashes on Windows to ensure proper pattern matching.Technical Details
The existing
utils.escape_special_charactersutility was not suitable for this fix as it only handles parentheses and curly braces in paths, not the fundamental path separator difference between Unix (/) and Windows (\).The solution implements OS-specific path normalization in
is_folder_ignored()by converting forward slashes to backslashes on Windows systems before pattern matching withvim.fn.match().Testing
Tested on Windows 10 with Zig build process. The
.zig-cachedirectory is now properly ignored, and existing defaults likenode_modulesnow correctly match on Windows paths.Closes #3178