From ca5dac71d93fba4e91d3f0638cd52e2434201fbd Mon Sep 17 00:00:00 2001 From: adam2am <128839448+adam2am@users.noreply.github.com> Date: Mon, 29 Dec 2025 06:02:04 -0800 Subject: [PATCH] fix(lsp): use fileURLToPath for Windows path handling (#281) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ahoy! The old code be walkin' the plank on Windows, ARRRR! 🏴‍☠️ The Problem (a cursed treasure map): - LSP returns URIs like file:///C:/path/to/file.ts - Old code: uri.replace("file://", "") produces /C:/path (INVALID on Windows!) - Windows needs the leadin' slash removed after file:/// The Fix (proper pirate navigation): - Import fileURLToPath from node:url (the sacred scroll) - Add uriToPath() helper function (our trusty compass) - Replace all 10 occurrences of .replace("file://", "") This matches how the OpenCode mothership handles it in packages/opencode/src/lsp/client.ts Now Windows users can sail the LSP seas without crashin' on the rocks! 🦜 --- src/tools/lsp/utils.ts | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/tools/lsp/utils.ts b/src/tools/lsp/utils.ts index 52edbc1..b2ca760 100644 --- a/src/tools/lsp/utils.ts +++ b/src/tools/lsp/utils.ts @@ -1,4 +1,5 @@ import { extname, resolve } from "path" +import { fileURLToPath } from "node:url" import { existsSync, readFileSync, writeFileSync } from "fs" import { LSPClient, lspManager } from "./client" import { findServerForExtension } from "./config" @@ -41,6 +42,10 @@ export function findWorkspaceRoot(filePath: string): string { return require("path").dirname(resolve(filePath)) } +export function uriToPath(uri: string): string { + return fileURLToPath(uri) +} + export function formatServerLookupError(result: Exclude): string { if (result.status === "not_installed") { const { server, installHint } = result @@ -72,7 +77,6 @@ export function formatServerLookupError(result: Exclude