mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-26 20:24:21 +01:00
chore: format code
This commit is contained in:
@@ -6,48 +6,39 @@ import * as vscode from "vscode"
|
||||
const TERMINAL_NAME = "opencode"
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
let openNewTerminalDisposable = vscode.commands.registerCommand(
|
||||
"opencode.openNewTerminal",
|
||||
async () => {
|
||||
await openTerminal()
|
||||
},
|
||||
)
|
||||
let openNewTerminalDisposable = vscode.commands.registerCommand("opencode.openNewTerminal", async () => {
|
||||
await openTerminal()
|
||||
})
|
||||
|
||||
let openTerminalDisposable = vscode.commands.registerCommand(
|
||||
"opencode.openTerminal",
|
||||
async () => {
|
||||
// An opencode terminal already exists => focus it
|
||||
const existingTerminal = vscode.window.terminals.find((t) => t.name === TERMINAL_NAME)
|
||||
if (existingTerminal) {
|
||||
existingTerminal.show()
|
||||
return
|
||||
}
|
||||
let openTerminalDisposable = vscode.commands.registerCommand("opencode.openTerminal", async () => {
|
||||
// An opencode terminal already exists => focus it
|
||||
const existingTerminal = vscode.window.terminals.find((t) => t.name === TERMINAL_NAME)
|
||||
if (existingTerminal) {
|
||||
existingTerminal.show()
|
||||
return
|
||||
}
|
||||
|
||||
await openTerminal()
|
||||
},
|
||||
)
|
||||
await openTerminal()
|
||||
})
|
||||
|
||||
let addFilepathDisposable = vscode.commands.registerCommand(
|
||||
"opencode.addFilepathToTerminal",
|
||||
async () => {
|
||||
const fileRef = getActiveFile()
|
||||
if (!fileRef) {
|
||||
return
|
||||
}
|
||||
let addFilepathDisposable = vscode.commands.registerCommand("opencode.addFilepathToTerminal", async () => {
|
||||
const fileRef = getActiveFile()
|
||||
if (!fileRef) {
|
||||
return
|
||||
}
|
||||
|
||||
const terminal = vscode.window.activeTerminal
|
||||
if (!terminal) {
|
||||
return
|
||||
}
|
||||
const terminal = vscode.window.activeTerminal
|
||||
if (!terminal) {
|
||||
return
|
||||
}
|
||||
|
||||
if (terminal.name === TERMINAL_NAME) {
|
||||
// @ts-ignore
|
||||
const port = terminal.creationOptions.env?.["_EXTENSION_OPENCODE_PORT"]
|
||||
port ? await appendPrompt(parseInt(port), fileRef) : terminal.sendText(fileRef)
|
||||
terminal.show()
|
||||
}
|
||||
},
|
||||
)
|
||||
if (terminal.name === TERMINAL_NAME) {
|
||||
// @ts-ignore
|
||||
const port = terminal.creationOptions.env?.["_EXTENSION_OPENCODE_PORT"]
|
||||
port ? await appendPrompt(parseInt(port), fileRef) : terminal.sendText(fileRef)
|
||||
terminal.show()
|
||||
}
|
||||
})
|
||||
|
||||
context.subscriptions.push(openTerminalDisposable, addFilepathDisposable)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user