mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-24 06:45:22 +00:00
chore: cleanup
This commit is contained in:
@@ -48,7 +48,6 @@ export namespace FileWatcher {
|
||||
const state = Instance.state(
|
||||
async () => {
|
||||
log.info("init")
|
||||
const dir = Instance.directory
|
||||
const cfg = await Config.get()
|
||||
const backend = (() => {
|
||||
if (process.platform === "win32") return "windows"
|
||||
@@ -66,13 +65,11 @@ export namespace FileWatcher {
|
||||
|
||||
const subscribe: ParcelWatcher.SubscribeCallback = (err, evts) => {
|
||||
if (err) return
|
||||
void Instance.run(dir, () => {
|
||||
for (const evt of evts) {
|
||||
if (evt.type === "create") Bus.publish(Event.Updated, { file: evt.path, event: "add" })
|
||||
if (evt.type === "update") Bus.publish(Event.Updated, { file: evt.path, event: "change" })
|
||||
if (evt.type === "delete") Bus.publish(Event.Updated, { file: evt.path, event: "unlink" })
|
||||
}
|
||||
})
|
||||
for (const evt of evts) {
|
||||
if (evt.type === "create") Bus.publish(Event.Updated, { file: evt.path, event: "add" })
|
||||
if (evt.type === "update") Bus.publish(Event.Updated, { file: evt.path, event: "change" })
|
||||
if (evt.type === "delete") Bus.publish(Event.Updated, { file: evt.path, event: "unlink" })
|
||||
}
|
||||
}
|
||||
|
||||
const subs: ParcelWatcher.AsyncSubscription[] = []
|
||||
|
||||
@@ -41,7 +41,6 @@ export namespace LSPClient {
|
||||
|
||||
export async function create(input: { serverID: string; server: LSPServer.Handle; root: string }) {
|
||||
const l = log.clone().tag("serverID", input.serverID)
|
||||
const dir = Instance.directory
|
||||
l.info("starting client")
|
||||
|
||||
const connection = createMessageConnection(
|
||||
@@ -59,7 +58,7 @@ export namespace LSPClient {
|
||||
const exists = diagnostics.has(filePath)
|
||||
diagnostics.set(filePath, params.diagnostics)
|
||||
if (!exists && input.serverID === "typescript") return
|
||||
void Instance.run(dir, () => Bus.publish(Event.Diagnostics, { path: filePath, serverID: input.serverID }))
|
||||
Bus.publish(Event.Diagnostics, { path: filePath, serverID: input.serverID })
|
||||
})
|
||||
connection.onRequest("window/workDoneProgress/create", (params) => {
|
||||
l.info("window/workDoneProgress/create", params)
|
||||
|
||||
@@ -79,13 +79,6 @@ export const Instance = {
|
||||
return input.fn()
|
||||
})
|
||||
},
|
||||
async run<R>(directory: string, fn: () => R): Promise<R | undefined> {
|
||||
const existing = cache.get(Filesystem.resolve(directory))
|
||||
if (!existing) return
|
||||
const ctx = await existing.catch(() => undefined)
|
||||
if (!ctx) return
|
||||
return context.provide(ctx, fn)
|
||||
},
|
||||
get directory() {
|
||||
return context.use().directory
|
||||
},
|
||||
|
||||
@@ -118,7 +118,6 @@ export namespace Pty {
|
||||
|
||||
export async function create(input: CreateInput) {
|
||||
const id = Identifier.create("pty", false)
|
||||
const dir = Instance.directory
|
||||
const command = input.command || Shell.preferred()
|
||||
const args = input.args || []
|
||||
if (command.endsWith("sh")) {
|
||||
@@ -195,13 +194,11 @@ export namespace Pty {
|
||||
session.bufferCursor += excess
|
||||
})
|
||||
ptyProcess.onExit(({ exitCode }) => {
|
||||
void Instance.run(dir, () => {
|
||||
if (session.info.status === "exited") return
|
||||
log.info("session exited", { id, exitCode })
|
||||
session.info.status = "exited"
|
||||
Bus.publish(Event.Exited, { id, exitCode })
|
||||
remove(id)
|
||||
})
|
||||
if (session.info.status === "exited") return
|
||||
log.info("session exited", { id, exitCode })
|
||||
session.info.status = "exited"
|
||||
Bus.publish(Event.Exited, { id, exitCode })
|
||||
remove(id)
|
||||
})
|
||||
Bus.publish(Event.Created, { info })
|
||||
return info
|
||||
|
||||
Reference in New Issue
Block a user