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

[vscode] fix fetchTasks to no longer filter modified configured tasks #8399

Closed
wants to merge 1 commit into from

Conversation

allaVolkov
Copy link

related to: #7681

Signed-off-by: Alla Volkov alla.volkov@sap.com

What it does

fetchTasks filters out some configured tasks from the tasks.json file.
It happens when an auto detected task is configured and some of its properties are then changed in the tasks.json file.

Management of the tasks from the tasks.json file separates them into two groups:

  • customized tasks
  • configured tasks

When fetchTasks is executed, the heuristic looks for matched original auto detected task for each customized task. The search is strict and compares each property from the task definition. In the case of a modified task, the match fails, and the task is filtered out. The PR resolves this problem by assigning these tasks to the group of configured tasks instead.

How to test

  1. Clone https://github.com/allaVolkov/test-echo-task-provider which is a VS Code extension that registers echo task provider.
  2. npm install
  3. npm run compile
  4. vsce package
  5. Deploy the result vsix file to theia
  6. Run theia
  7. Select command RunTasks… from the command palette
    Observe 2 auto detected tasks:
  • echo: task 1
  • echo: task 2
  1. Configure task 1
  2. Update created tasks.json file:
  • change label to task 3
  • change text to Configured text
  1. Select again command RunTasks… from the command palette
  2. Check the list of tasks:  
  • task 3
  • echo: task 1
  • echo: task 2

Prior to this PR task 3 was missing in the list of tasks. In VS Code it was listed.

Review checklist

Reminder for reviewers

@vince-fugnitto vince-fugnitto added the tasks issues related to the task system label Aug 18, 2020
@allaVolkov
Copy link
Author

@akosyakov
@RomanNikitenko
@tsmaeder

Whom please I can contact to start reviewing this PR?

Thank you

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the changes superficially for the moment, please address the test since we should not be disabling the rules (it leaves us with incorrect formatting, suppressed potential warnings and errors). Also, please squash your commits (into a single commit) when you are ready for another round of review.

packages/task/src/browser/task-configurations.spec.ts Outdated Show resolved Hide resolved
packages/task/src/browser/task-configurations.spec.ts Outdated Show resolved Hide resolved
@@ -139,9 +139,19 @@ export class TaskConfigurations implements Disposable {
if (detected) {
// there might be a provided task that has a different scope from the task we're inspecting
detectedTasksAsConfigured.push({ ...detected, ...cus });
} else {
if (configuredTasksMap.has(rootFolder)) {
configuredTasksMap.get(rootFolder)!.set(cus['label'], cus as TaskConfiguration);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we be sure that the label field is not undefined here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your concern and maybe I have to add a check here.
The reason of such usage of label field is caused by the following:

PR modifies method getTasks.
This method processes 2 groups of tasks:

  • taskCustomizationMap
  • tasksMap

These groups are created in the method reorganizeTasks. As you can see, the existing code:

addConfiguredTask(scopeKey, transformedTask['label'] as string, transformedTask);

uses the field label without additional check.
If task is not detected it's assigned to tasksMap group assuming it has field label.
Don't we miss the check already here?

CHANGELOG.md Outdated
@@ -2,6 +2,7 @@

## v1.5.0

- [tasks] fix vscode.tasks.fetchTasks to no longer filter modified configured tasks aligning to VS Code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When fixing a bug, please add a link to the issue for easy reference.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

packages/task/src/browser/task-configurations.spec.ts Outdated Show resolved Hide resolved
}
}
}
const configuredTasks = Array.from(configuredTasksMap.values()).reduce((acc, labelConfigMap) => acc.concat(Array.from(labelConfigMap.values())), [] as TaskConfiguration[]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand the code, this will still remove any tasks of type "shell", etc (which don't have a task definition) that have the same label (since we're using a map by label). Is the behaviour after this change aligned with VS Code as described in #7672 (comment) ? If I add the following to a tasks.json file:

        {
			"label": "My Task",
			"type": "shell",
			"command": "echo Hello",
			"problemMatcher": []
		},
		{
			"label": "My Task",
			"type": "shell",
			"command": "echo Hello",
			"problemMatcher": []
		}
}

and then do "run tasks", I see two tasks, as I read the code here, we would only get one task.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, the purpose of this PR is not to cover all delta of the fetchTasks between Theia and VSCode.
It covers only specific case that we run into, implementing VSCode extension with task provider.

related to: eclipse-theia#7681

Signed-off-by: Alla Volkov <alla.volkov@sap.com>
@lidortal
Copy link

Any update on this PR?

@JonasHelming JonasHelming added the decision_needed issues that require decisions on ways forward (ex: if they should be updated or closed) label Mar 21, 2022
@tsmaeder
Copy link
Contributor

I'm not sure this PR does the right thing: according to https://code.visualstudio.com/docs/editor/tasks#_customizing-autodetected-tasks, an entry in a tasks.json file must be either of type shell or process or otherwise customize an auto-detected task. So having a task in task.json that does not fulfill either condition could also be considered an error. I lack the time right now to work myself into the tasks system once more in order to form an opinion.

I've opened #10850 exactly because we don't really have a good handle on questions like this. I would vote for keeping this PR open unmerged. When we attack the tasks once more, we can decide for/against it.

@tsmaeder tsmaeder removed the decision_needed issues that require decisions on ways forward (ex: if they should be updated or closed) label Mar 29, 2022
@RomanNikitenko RomanNikitenko removed their request for review July 14, 2022 16:21
@vince-fugnitto
Copy link
Member

@tsmaeder the pull-request is over a year old and based on your last comment you don't believe it is going in the right direction. Is it safe to close the issue to keep the list of open pull-requests more manageable?

@tsmaeder
Copy link
Contributor

As much as I hate doing this, I think the likelihood of this one getting merged any time soon is low.

@tsmaeder tsmaeder closed this May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tasks issues related to the task system
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants