vscode: Extend tasks API to allow programmatic problem matching
The new tasks APIs (fetchTask(), executeTask(), task events…) makes it more convenient to use vscode’s own task system to spawn child process (as opposed to using something like child_process
, for example). Still, AFAICT, there are two bits missing in the API:
-
A method to get the underlying
Terminal
instance of a running task (maybe throughTaskExecution
?); -
Events that would be fired whenever something is written in the process’ stdout/stderr (that would probably go in the
Terminal
instance itself)
This would be very useful to implement UI feedback (i.e progess notifications) while using vscode’s task system. Right now, the only way I see to do that is to spawn my own proces, create an output channel and handle problem matching myself…
Does that make sense?
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 23
- Comments: 27 (26 by maintainers)
Actually that tasks are executed in a terminal is still an implementation details (there are even legacy tasks which don’t even run in a terminal). In addition there are requests to be able to run a task in a external terminal. As soon as we would add such a API we are basically hooked into this. This is why I feel very reluctant of adding this in the API.
Adding access to stdout / stderr is a request we do have and I fully support having in the API.
@Tyriar I see… It seems that this really isin’t suited to get stdout from a task started in an integrated terminal… 😦
I will open the issue for the processId bug, I guess I can work around the other issues if I have a reliable way of getting the PID of the process currently running in the terminal
Just found out that there is already a
onDidWrite
proposed inTerminal
. And that there is aonDidOpenTerminal
inwindow
. Now I just need a way to match Terminals to Tasks…I think I could provide a PR that would either expose a
Terminal
fromTask
or aTask
from aTerminal
? Which one do you guys think it would make more sense? @Tyriar @dbaeumer