Skip to content

Conversation

@yimingll
Copy link
Contributor

Summary

Fix LSP tools failing on Windows with "unresolvable URI" error.

Fixes #684

Changes

1. src/tools/lsp/client.ts

Use pathToFileURL() from node:url instead of string template for file URIs:

// Before (broken on Windows)
const rootUri = `file://${this.root}`
textDocument: { uri: `file://${absPath}` }

// After (works on all platforms)
import { pathToFileURL } from "node:url"
const rootUri = pathToFileURL(this.root).href
textDocument: { uri: pathToFileURL(absPath).href }

Why: On Windows, file://${path} generates invalid URIs like file://E:\path instead of file:///E:/path.

2. src/tools/lsp/utils.ts

Fix findWorkspaceRoot() loop condition:

// Before (Unix only)
while (dir !== "/")

// After (cross-platform)
let prevDir = ""
while (dir !== prevDir)

Why: On Windows, the root is C:\ not /, so the original condition never terminates properly.

Testing

Tested on Windows 11 with clangd 21.1.8:

  • lsp_hover - works
  • lsp_document_symbols - works
  • lsp_goto_definition - works
  • lsp_find_references - works
  • lsp_prepare_rename - works
  • lsp_workspace_symbols - works
  • lsp_diagnostics - works
  • lsp_code_actions - works

…RI generation

- Use pathToFileURL() from node:url instead of string template for file URIs
- Fix findWorkspaceRoot() loop condition to work on both Windows and Unix

Fixes code-yeongyu#684
@github-actions
Copy link
Contributor

github-actions bot commented Jan 11, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@yimingll
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Jan 11, 2026
@code-yeongyu code-yeongyu merged commit 8ed3f7e into code-yeongyu:dev Jan 11, 2026
2 of 3 checks passed
kdcokenny pushed a commit that referenced this pull request Jan 13, 2026
kdcokenny pushed a commit that referenced this pull request Jan 13, 2026
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.

LSP tools fail on Windows: Invalid file URI generation

2 participants