fix(win32): Normalise LSP paths on windows (fixes lua) (#5597)

This commit is contained in:
Luke Parker
2025-12-16 10:01:03 +10:00
committed by GitHub
parent 89a4f1c1ae
commit 27e826eba6
5 changed files with 44 additions and 22 deletions

View File

@@ -11,6 +11,7 @@ import type { LSPServer } from "./server"
import { NamedError } from "@opencode-ai/util/error"
import { withTimeout } from "../util/timeout"
import { Instance } from "../project/instance"
import { Filesystem } from "../util/filesystem"
export namespace LSPClient {
const log = Log.create({ service: "lsp.client" })
@@ -47,14 +48,15 @@ export namespace LSPClient {
const diagnostics = new Map<string, Diagnostic[]>()
connection.onNotification("textDocument/publishDiagnostics", (params) => {
const path = fileURLToPath(params.uri)
const filePath = Filesystem.normalizePath(fileURLToPath(params.uri))
l.info("textDocument/publishDiagnostics", {
path,
path: filePath,
count: params.diagnostics.length,
})
const exists = diagnostics.has(path)
diagnostics.set(path, params.diagnostics)
const exists = diagnostics.has(filePath)
diagnostics.set(filePath, params.diagnostics)
if (!exists && input.serverID === "typescript") return
Bus.publish(Event.Diagnostics, { path, serverID: input.serverID })
Bus.publish(Event.Diagnostics, { path: filePath, serverID: input.serverID })
})
connection.onRequest("window/workDoneProgress/create", (params) => {
l.info("window/workDoneProgress/create", params)
@@ -181,14 +183,16 @@ export namespace LSPClient {
return diagnostics
},
async waitForDiagnostics(input: { path: string }) {
input.path = path.isAbsolute(input.path) ? input.path : path.resolve(Instance.directory, input.path)
log.info("waiting for diagnostics", input)
const normalizedPath = Filesystem.normalizePath(
path.isAbsolute(input.path) ? input.path : path.resolve(Instance.directory, input.path),
)
log.info("waiting for diagnostics", { path: normalizedPath })
let unsub: () => void
return await withTimeout(
new Promise<void>((resolve) => {
unsub = Bus.subscribe(Event.Diagnostics, (event) => {
if (event.properties.path === input.path && event.properties.serverID === result.serverID) {
log.info("got diagnostics", input)
if (event.properties.path === normalizedPath && event.properties.serverID === result.serverID) {
log.info("got diagnostics", { path: normalizedPath })
unsub?.()
resolve()
}