From 2e938d9da1589e1e00b9739c5e6c8dc72dda872a Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Mon, 26 May 2025 22:08:50 -0400 Subject: Standardize API parameters to camelCase and improve LSP client reliability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Convert tool parameters from snake_case to camelCase for consistency - Add file existence check in LSP client before opening files - Fix version increment timing in LSP textDocument operations - Optimize session token tracking using onStepFinish callback - Add debugging logs for diagnostics troubleshooting 🤖 Generated with opencode Co-Authored-By: opencode --- js/src/lsp/client.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'js/src/lsp/client.ts') diff --git a/js/src/lsp/client.ts b/js/src/lsp/client.ts index 73a216b06..0ad7be6e7 100644 --- a/js/src/lsp/client.ts +++ b/js/src/lsp/client.ts @@ -51,6 +51,7 @@ export namespace LSPClient { log.info("textDocument/publishDiagnostics", { path, }); + console.log(path, params); diagnostics.set(path, params.diagnostics); Bus.publish(Event.Diagnostics, { path, serverID: input.serverID }); }); @@ -129,7 +130,9 @@ export namespace LSPClient { }, notify: { async open(input: { path: string }) { - const text = await Bun.file(input.path).text(); + const file = Bun.file(input.path); + if (!file.exists()) return; + const text = await file.text(); const opened = files.has(input.path); if (!opened) { log.info("textDocument/didOpen", input); @@ -140,8 +143,8 @@ export namespace LSPClient { textDocument: { uri: `file://` + input.path, languageId, - version: 1, - text: text, + version: ++version, + text, }, }); files.add(input.path); @@ -150,11 +153,10 @@ export namespace LSPClient { log.info("textDocument/didChange", input); diagnostics.delete(input.path); - version++; await connection.sendNotification("textDocument/didChange", { textDocument: { uri: `file://` + input.path, - version, + version: ++version, }, contentChanges: [ { @@ -168,7 +170,7 @@ export namespace LSPClient { return diagnostics; }, async waitForDiagnostics(input: { path: string }) { - log.info("refreshing diagnostics", input); + log.info("waiting for diagnostics", input); let unsub: () => void; let timeout: NodeJS.Timeout; return await Promise.race([ @@ -184,7 +186,6 @@ export namespace LSPClient { resolve(); } }); - await result.notify.open(input); }), new Promise((resolve) => { timeout = setTimeout(() => { -- cgit v1.2.3