Fix rewatch lockfile detection on Windows#1160
Conversation
…lookup logic Refactor findProjectRootOfFile to use separate functions for file vs directory lookups, eliminating confusing boolean parameter and fixing the case where exact directory matches were incorrectly excluded.
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows lockfile detection issue by refactoring the findProjectRootOfFile function to eliminate a confusing boolean parameter. The refactoring splits the functionality into two separate functions: one for file lookups (findProjectRootOfFile) and one for directory lookups (findProjectRootOfDir), with the key difference being that directory lookups allow exact matches while file lookups exclude them.
Key Changes:
- Separated file and directory lookup logic into distinct functions with clear semantics
- Removed the confusing
allowDirboolean parameter fromfindProjectRootOfFile - Added comprehensive JSDoc documentation for the new function structure
- Updated all call sites to use the appropriate function based on whether a file or directory is being searched
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| server/src/utils.ts | Refactored findProjectRootOfFile into separate findProjectRootOfFile and findProjectRootOfDir functions with helper functions findProjectRootContainingFile and findProjectRootMatchingDir for clarity; added debug logging statements |
| server/src/incrementalCompilation.ts | Updated to use new findProjectRootOfDir function for directory lookups |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@nojaf this is great -- much cleaner |
I would not say that we nailed down everything related to searching monorepo structures.
For the runtime and binary, in a best case a We also don't quite take anything npm/pnpm/bun specific into account of a monorepo. |
Refactor findProjectRootOfFile to use separate functions for file vs directory lookups, eliminating confusing boolean parameter and fixing the case where exact directory matches were incorrectly excluded.
This fixed #1155 for me on Windows.