How to associate Terminal opened for task with CustomExecution #1256
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.
-
I'm implementing a
vscode.CustomExecution
to integrate a custom build system. I want to add some buttons to interact with a task backed by this custom implementation into the terminal toolbar. I know how to put buttons into the terminal toolbar in general and about howwhen
clauses can be used inpackage.json
to control when these buttons show up. My problem is I don't know how to tell whichvscode.Terminal
is the one opened for myvscode.CustomExecution
so I can set some context keys when it is active and get back to my custom task instance from the command handlers.Basically I want to write code like this
but don't know how to do the
isTerminalOfMyCustomTask
andmyCustomExecutionInTerminal
.I was hoping I could use
creationOptions
of the terminalto correlate execution with the terminal because I expected the
creationOptions
to be theExtensionTerminalOptions
which would contain the reference to thevscode.Pseudoterminal
I created in my custom task execution (So I could simply have aMap<vscode.Pseudoterminal, MyCustomExecution>
somewhere that gets populated by the custom execution so it can be looked up later). This is not the case though, the the terminal is created withTerminalOptions
(I think this because the object I see has propertiesshellPath
andshellArgs
which only exist invscode.TerminalOptions
) - not sure if this is a bug and should be reported as such on its own, an oversight or I'm missing something here...Beta Was this translation helpful? Give feedback.
All reactions