Only fire workspace task events for effective scope #10335
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What it does
Fixes a minor, intermittent bug that causes tasks in folder scope to be double listed as occurring in both folder and workspace scope in an unsaved (single-root) workspace.
How to test
The bug depends on a race condition, but the basic issue is this:
theia/packages/task/src/browser/task-configuration-manager.ts
Lines 227 to 246 in 008c2a1
When we fire those events, this listener
theia/packages/task/src/browser/task-configurations.ts
Lines 97 to 107 in 008c2a1
kicks in and populates a list of tasks by scope. We always fire events for folder scope, which is why we only want to fire them for workspace scope if it's different.
The race condition comes in because if the preference provider for
newDelegate
happens not to have read its configuration when the event on line 243 is fired, then the listener finds no tasks for that scope, and so we don't see any duplicates. If the preference provider has read its configuration, then we get the same tasks listed in both folder and workspace scope.If you really want to reproduce the bug, replace line 243 with
which will guarantee that the configuration has been read then
tasks.json
tasks.json
are all listed twice, once in workspace scope, once in folder scope.Review checklist
Reminder for reviewers
Signed-off-by: Colin Grant [email protected]