Skip to content

Conversation

@kjanat
Copy link

@kjanat kjanat commented Nov 6, 2025

Summary

Fixes a language server initialization error on Windows where PowerShell Editor Services failed to start due to backslashes in absolute paths being misinterpreted as escape characters.

Problem

On Windows, the extension was passing absolute paths with backslashes (e.g., C:\Users\...) to PowerShell commands. PowerShell interprets backslashes as escape characters, causing errors like:

Import-Module: Cannot find drive. A drive with the name '\C' does not exist.
Start-EditorServices: The term 'Start-EditorServices' is not recognized...
Full error

Language server powershell-es:

initializing server powershell-es, id 8: Server reset the connection
-- stderr --
�[31;1mImport-Module: �[31;1mCannot find drive. A drive with the name '\C' does not exist.�[0m
�[31;1mStart-EditorServices: �[31;1mThe term 'Start-EditorServices' is not recognized as a name of a cmdlet, function, script file, or executable program.�[0m
�[31;1m�[31;1mCheck the spelling of the name, or if a path was included, verify that the path is correct and try again.�[0m

Solution

  • Normalize LSP paths by converting backslashes to forward slashes before passing to PowerShell
  • PowerShell accepts forward slashes on all platforms (Windows, macOS, Linux), making this a safe cross-platform solution
  • Apply clippy suggestions for more idiomatic Rust code
  • Update dependencies including zed_extension_api from v0.2.0 to v0.7.0

Changes

  • Convert Windows backslashes to forward slashes in language_server_path() method (src/powershell.rs)
  • Update extension dependencies to latest versions
  • Bump extension version to 0.3.1
  • Apply clippy auto-fixes for improved code quality

Testing

Tested on Windows with PowerShell 7 where the language server now initializes successfully without path-related errors.

On Windows, absolute paths use backslashes, which can be misinterpreted
by PowerShell scripts or commands expecting Unix-style forward-slash
paths.

This change normalizes the Language Server Protocol (LSP) path by
replacing backslashes with forward slashes, ensuring compatibility and
resolving an initialization error on Windows.
Updates the PowerShell extension to use more idiomatic Rust patterns:

- Replaces `map_or` with `is_ok_and` for clearer file existence checks
- Uses `ok_or` instead of `ok_or_else` for static error messages
  (avoiding unnecessary closure allocations)
- Removes an unnecessary reference when setting the installation status

Applied: cargo clippy --fix --lib -p powershell
Updates the `zed_extension_api` from v0.2.0 to v0.7.0, along with
other related dependencies.
This change addresses a language server initialization issue.

The extension version is also bumped to 0.3.1.
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.

1 participant