summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-08-11 21:36:05 -0400
committerDax Raad <[email protected]>2025-08-11 21:36:05 -0400
commitf03fae03e54b150b368bc02ca4e2f5753f34671d (patch)
treef29d78fdef2671058965f0bbe8c761cbec2cfd07
parentbb14a955a03855a79cb08c349e025a5cb8fc2404 (diff)
downloadopencode-f03fae03e54b150b368bc02ca4e2f5753f34671d.tar.gz
opencode-f03fae03e54b150b368bc02ca4e2f5753f34671d.zip
switch back to didUpdate instead of closing and opening file
-rw-r--r--packages/opencode/src/cli/cmd/debug/lsp.ts4
-rw-r--r--packages/opencode/src/lsp/client.ts15
2 files changed, 15 insertions, 4 deletions
diff --git a/packages/opencode/src/cli/cmd/debug/lsp.ts b/packages/opencode/src/cli/cmd/debug/lsp.ts
index ac1bac7c1..91b13df43 100644
--- a/packages/opencode/src/cli/cmd/debug/lsp.ts
+++ b/packages/opencode/src/cli/cmd/debug/lsp.ts
@@ -2,6 +2,7 @@ import { LSP } from "../../../lsp"
import { bootstrap } from "../../bootstrap"
import { cmd } from "../cmd"
import { Log } from "../../../util/log"
+import { appendFile } from "fs/promises"
export const LSPCommand = cmd({
command: "lsp",
@@ -17,6 +18,9 @@ const DiagnosticsCommand = cmd({
await bootstrap({ cwd: process.cwd() }, async () => {
await LSP.touchFile(args.file, true)
console.log(await LSP.diagnostics())
+ await appendFile(args.file, `\nconst x: number = "foo"`)
+ await LSP.touchFile(args.file, true)
+ console.log(await LSP.diagnostics())
})
},
})
diff --git a/packages/opencode/src/lsp/client.ts b/packages/opencode/src/lsp/client.ts
index c63e02592..509e982eb 100644
--- a/packages/opencode/src/lsp/client.ts
+++ b/packages/opencode/src/lsp/client.ts
@@ -126,19 +126,26 @@ export namespace LSPClient {
input.path = path.isAbsolute(input.path) ? input.path : path.resolve(app.path.cwd, input.path)
const file = Bun.file(input.path)
const text = await file.text()
+ const extension = path.extname(input.path)
+ const languageId = LANGUAGE_EXTENSIONS[extension] ?? "plaintext"
+
const version = files[input.path]
if (version !== undefined) {
- diagnostics.delete(input.path)
- await connection.sendNotification("textDocument/didClose", {
+ const next = version + 1
+ files[input.path] = next
+ log.info("textDocument/didChange", { path: input.path, version: next })
+ await connection.sendNotification("textDocument/didChange", {
textDocument: {
uri: `file://` + input.path,
+ version: next,
},
+ contentChanges: [{ text }],
})
+ return
}
+
log.info("textDocument/didOpen", input)
diagnostics.delete(input.path)
- const extension = path.extname(input.path)
- const languageId = LANGUAGE_EXTENSIONS[extension] ?? "plaintext"
await connection.sendNotification("textDocument/didOpen", {
textDocument: {
uri: `file://` + input.path,