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

Contributed tasks aren't added to recent #94549

Merged
merged 3 commits into from
Apr 7, 2020
Merged

Conversation

alexr00
Copy link
Member

@alexr00 alexr00 commented Apr 6, 2020

This PR fixes #94547

@alexr00 alexr00 self-assigned this Apr 6, 2020
@alexr00 alexr00 requested a review from dbaeumer April 6, 2020 14:41
@alexr00 alexr00 added this to the March 2020 milestone Apr 6, 2020
@alexr00
Copy link
Member Author

alexr00 commented Apr 6, 2020

Background info:
An extension contributed task gets a recently used key that notes that it is contributed.
However, now when recently used tasks are displayed we show them in the same way that tasks.json tasks (custom tasks) are shown (because that's the way we store them as recently used, just like in tasks.json).
This means that the key that the task is saved with doesn't match the key that we try to access it with later.

The fix is to save the task as recently used with the correct custom key instead of the incorrect contributed key.

tasks: [customizations]
}, TaskRunSource.System, custom, customized, TaskConfig.TaskConfigSource.TasksJson, true);
for (const configuration in customized) {
key = customized[configuration].getRecentlyUsedKey()!;
Copy link
Member

Choose a reason for hiding this comment

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

Why is the key a random key from the customized hash table ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The key is from here

public getRecentlyUsedKey(): string | undefined {

I start with a ContributedTask key, but I'm storing a CustomTask, so when I re-create the task later it will have a CustomTask key. To avoid this, I convert the ContributedTask into a CustomTask then use that key.

Copy link
Member

Choose a reason for hiding this comment

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

What I actually mean is the following: how can this piece of code be deterministic given that we loop over the keys in a hash table. There is no order associated with this. Or does it simply not matter.

Copy link
Member Author

Choose a reason for hiding this comment

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

There will be only one key in the hash table, since only one task is fed in. I will make that clearer.

Copy link
Member

Choose a reason for hiding this comment

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

OK. That explains it to me. Thanks.

@Tyriar Tyriar added the candidate Issue identified as probable candidate for fixing in the next release label Apr 6, 2020
tasks: [customizations]
}, TaskRunSource.System, custom, customized, TaskConfig.TaskConfigSource.TasksJson, true);
for (const configuration in customized) {
// There should only be one configuration in customized, but check that it matches the original task just to be sure.
Copy link
Member

Choose a reason for hiding this comment

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

What happens now if we do have a programming error somewhere and the keys are not the same. The we use the key from the beginning which to my understanding would be wrong. So shouldn't we simply assert this or ignore the task if something goes wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is effectively ignored later when the recents are read. However it would be better to ignore earlier (here) instead.

Copy link
Member

Choose a reason for hiding this comment

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

OK. That makes sense now to me. Are you planning to do any changes or do we go with the ignore later approach?

Copy link
Member Author

Choose a reason for hiding this comment

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

I made the change for ignoring here since it is better not to defer the problem.

@alexr00
Copy link
Member Author

alexr00 commented Apr 7, 2020

Thank you for the review!

@alexr00 alexr00 merged commit ea93548 into release/1.44 Apr 7, 2020
@alexr00 alexr00 deleted the alexr00/issue94547 branch April 7, 2020 11:42
@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
candidate Issue identified as probable candidate for fixing in the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants