Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion sdks/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,21 @@
"win": "ctrl+alt+K",
"linux": "ctrl+alt+K"
}
]
],
"configuration": {
"title": "opencode",
"properties": {
"opencode.tuiLocation": {
"type": "string",
"default": "editor",
"enum": [
"editor",
"terminal"
],
"description": "Where to open the opencode TUI: beside the current editor or in the terminal panel."
}
}
}
},
"scripts": {
"vscode:prepublish": "bun run package",
Expand Down
15 changes: 10 additions & 5 deletions sdks/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,26 @@ export function activate(context: vscode.ExtensionContext) {
}
})

context.subscriptions.push(openTerminalDisposable, addFilepathDisposable)
context.subscriptions.push(openNewTerminalDisposable, openTerminalDisposable, addFilepathDisposable)

async function openTerminal() {
// Create a new terminal in split screen
const config = vscode.workspace.getConfiguration("opencode")
const tuiLocation = config.get<string>("tuiLocation", "editor")
const port = Math.floor(Math.random() * (65535 - 16384 + 1)) + 16384
const terminal = vscode.window.createTerminal({
name: TERMINAL_NAME,
iconPath: {
light: vscode.Uri.file(context.asAbsolutePath("images/button-dark.svg")),
dark: vscode.Uri.file(context.asAbsolutePath("images/button-light.svg")),
},
location: {
viewColumn: vscode.ViewColumn.Beside,
preserveFocus: false,
},
location:
tuiLocation === "terminal"
? vscode.TerminalLocation.Panel
: {
viewColumn: vscode.ViewColumn.Beside,
preserveFocus: false,
},
env: {
_EXTENSION_OPENCODE_PORT: port.toString(),
OPENCODE_CALLER: "vscode",
Expand Down
Loading