Files
smartfile/readme.hints.md

1.2 KiB

SmartFile Implementation Hints

listFileTree Function Enhancement (ts/fs.ts:367-415)

Issue Fixed

The listFileTree function previously had inconsistent behavior with **/*.extension patterns across different systems and glob implementations. Some implementations would miss root-level files when using patterns like **/*.ts.

Solution Implemented

Modified the function to explicitly handle **/ patterns by:

  1. Detecting when a pattern starts with **/
  2. Extracting the file pattern after **/ (e.g., *.ts from **/*.ts)
  3. Running both the original pattern and the extracted root pattern
  4. Using a Set to deduplicate results and ensure consistent ordering

Key Benefits

  • Guarantees consistent behavior across all systems
  • Ensures both root-level and nested files are found with **/* patterns
  • Maintains backward compatibility
  • No performance degradation due to efficient deduplication

Test Coverage

Added comprehensive tests to verify:

  • Both root and nested files are found with **/*.ts
  • No duplicate entries in results
  • Edge cases with various file extensions work correctly

This fix ensures tools like tsbuild check **/*.ts work reliably across all systems.