Skip to content

Fix Windows path separator handling - #224

Open
hoklims wants to merge 1 commit into
sourcegraph:scipfrom
hoklims:agent/fix-windows-path-separator
Open

Fix Windows path separator handling#224
hoklims wants to merge 1 commit into
sourcegraph:scipfrom
hoklims:agent/fix-windows-path-separator

Conversation

@hoklims

@hoklims hoklims commented Aug 16, 2026

Copy link
Copy Markdown

What changed

  • replace the platform-derived regular expression with a separator expression that safely handles both \ and /
  • add a regression test covering Windows and POSIX paths

Why

On Windows, path.sep is \. Passing it directly to new RegExp() creates an invalid regular expression and crashes scip-python during module initialization. This addresses #210.

Accepting both separators also keeps package resolution robust when Python metadata contains mixed path styles.

Validation

  • npm test -- --runInBand — 2 suites, 8 tests passed
  • npm run check:prettier — passed
  • npm run build-agent — passed
  • native Windows indexing smoke — generated a SCIP index containing all 8 expected Python documents

@hoklims
hoklims marked this pull request as ready for review August 16, 2026 13:45
Copilot AI lite review requested due to automatic review settings August 16, 2026 13:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Windows startup crash in pyright-scip by removing the platform-derived RegExp(path.sep) (which is invalid on Windows) and replacing it with a safe separator-matching regex that works across both Windows (\) and POSIX (/) path styles.

Changes:

  • Replace new RegExp(path.sep, 'g') with a safe cross-platform separator regex (/[\\/]/g).
  • Add a regression test ensuring module resolution works with both Windows-style and POSIX-style separators in package file paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/pyright-scip/src/virtualenv/PythonEnvironment.ts Uses a safe, cross-platform separator regex to avoid Windows RegExp initialization crashes and handle mixed path styles.
packages/pyright-scip/src/virtualenv/PythonEnvironment.test.ts Adds coverage to confirm module resolution works for both \ and / separators.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants