fix(list): remove recursion and file limit for predictable directory listing #6167
+58
−82
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.
Problem
The
listtool had a fundamental design issue that caused unpredictable and confusing behavior:Example of the bug:
In a directory with 41 subdirectories:
But the
listtool would only show 2 directories:The other 39 directories were invisible because ripgrep's first 100 files happened to all be in those 2 directories.
Solution
Changed the
listtool to behave like a standard directory listing command (ls,os.listdir(), etc.):fs.readdir()instead of recursive ripgrep scanningChanges:
fs.readdir()withwithFileTypesfor direct, non-recursive listing/for clarityAfter the fix:
Same directory now correctly shows all 41 subdirectories plus files:
Benefits
lscommandlist→ show immediate children (likels)glob→ find files by pattern (likefind)grep→ search file contentsTesting
Tested with:
All cases now show complete, predictable output.