Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type property for preLaunchTask #223081

Closed
meganrogge opened this issue Jul 22, 2024 · 10 comments
Closed

Add type property for preLaunchTask #223081

meganrogge opened this issue Jul 22, 2024 · 10 comments
Assignees
Labels
feature-request Request for new features or functionality tasks Task system issues

Comments

@meganrogge
Copy link
Contributor

Idea from @alexr00:

In order to reduce the number of activations, we could add a type property to the preLaunchTask so that we know which extensions, if any, to activate when a user starts debugging and don't have to activate all of them.

No extensions are activated for type shell

preLaunchTask: {
      "name": "Ensure Prelaunch Dependencies",
      "type": "shell"
}

or

Only npm extension is activated

`"prelaunchTask": {
    "taskType": "npm",
    "taskLabel": "npm: build"
}
@meganrogge meganrogge self-assigned this Jul 22, 2024
@meganrogge meganrogge added tasks Task system issues feature-request Request for new features or functionality labels Jul 22, 2024
@meganrogge meganrogge added this to the August 2024 milestone Jul 22, 2024
@connor4312
Copy link
Member

Correct me if I'm wrong -- I don't know all the intricacies of the task system by far -- but doesn't the label string already reference a task defined in the tasks.json, and could we read the type from there?

@meganrogge
Copy link
Contributor Author

meganrogge commented Jul 22, 2024

the task might not be contributed in the tasks.json file - it might be contributed via the extension's call of registerTaskProvider

another issue - label is optional

@meganrogge
Copy link
Contributor Author

meganrogge commented Jul 22, 2024

Based on logging, I'm seeing only the relevant extension activated when I start debugging. Same for when I run the default build task.

Example using the terminal ext sample:

Image

@meganrogge
Copy link
Contributor Author

So, I believe that we're only activating all extension providers when we cannot find the right one in the tasks.json file.

@meganrogge meganrogge removed this from the August 2024 milestone Jul 22, 2024
@meganrogge
Copy link
Contributor Author

meganrogge commented Jul 22, 2024

One can already add a type property but needs to also provide a script.

The repro for this is set preLaunchTask to be the default build task.

Image

@meganrogge
Copy link
Contributor Author

So ideally, we'd check if the tasks.json file contains the default build task before activating all providers.

@connor4312
Copy link
Member

connor4312 commented Jul 22, 2024

Referencing preLaunchTask: "npm: start" with this in my tasks.json, it still activates all task providers before running it:

    {
      "type": "npm",
      "script": "start",
      "problemMatcher": [],
      "label": "npm: start",
      "detail": "echo hello"
    }

It's hard for me to give good input here as I don't really know how tasks work in relation to preLaunchTask. In the docs we only say that prelaunchTask can be set to "the label of a task specified in tasks.json". I don't have a good grasp on any implicit behavior outside of that. It seems like:

  • They can reference labels in the tasks.json, as documented
  • They can also reference tasks provided on the fly by task providers -- how would a user know what label to set this to when provided dynamically? Or is this only really relevant to programmatically generated launch.jsons?
  • As discussed in 157957, they can be objects, but only for task types that are provided by extensions. Is it the case that this just allows extension-provided tasks to be "inlined" into the config? (There's no intellisense here so we don't provide any hints for users to go off of)

@meganrogge
Copy link
Contributor Author

meganrogge commented Jul 22, 2024

I think I have a solution. We should only be activating when the build task is actually run. I see we're activating earlier than that, which can be prevented.

@meganrogge
Copy link
Contributor Author

Closing this issue. We don't need to add a type property, just need to be smarter about when and what we activate.

@meganrogge meganrogge closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2024
@meganrogge
Copy link
Contributor Author

meganrogge commented Jul 22, 2024

Currently, when ${defaultBuildTask} is used as a preLaunchTask we fetch all tasks, activating all providers, then filter to find the default build task.

Instead, I think we should try to find a default task in the tasks.json, wait to activate until it's run.

If there isn't one, then we'll fall back to the current behavior - activating all providers.

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality tasks Task system issues
Projects
None yet
Development

No branches or pull requests

2 participants