How to associate Terminal opened for task with CustomExecution #1256
-
I'm implementing a Basically I want to write code like this vscode.window.onDidChangeActiveTerminal(term => {
void vscode.commands.executeCommand('setContext', `isMyCustomTask`, isTerminalOfMyCustomTask(term))
})
vscode.commands.registerCommand("commandForCustomTask", () => {
const term = vscode.window.activeTerminal
const exec = myCustomExecutionInTerminal(term)
actOnCustomExecution(exec)
}) but don't know how to do the I was hoping I could use export interface Terminal {
readonly creationOptions: Readonly<TerminalOptions | ExtensionTerminalOptions>;
}
export interface ExtensionTerminalOptions {
pty: Pseudoterminal;
} to correlate execution with the terminal because I expected the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
Hi vaclavHala, To associate a vscode.Terminal with a vscode.CustomExecution and identify it later, you can maintain a mapping between custom executions and terminals using a unique identifier (e.g., a UUID) for each execution. When creating a terminal for your custom execution, include this unique identifier in the terminal's name or environment variables. Then, implement functions to check if an active terminal corresponds to one of your custom executions by matching this identifier in the terminal's name or environment variables. This approach allows you to set context keys or perform actions specific to the terminal associated with your custom execution. I got this suggestion from copilot so for more specific examples, you can have it update your code to experiment. Let me know how it goes & reopen if you have more questions. /r |
Beta Was this translation helpful? Give feedback.
Thanks for the info. I see what you mean. I don't think there's a way to know that at the moment.