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

Extracted the taskId criteria while searching the input #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

roussak
Copy link

@roussak roussak commented Feb 4, 2025

The very presence of an "Id" in the name suggests that this entity must be something unique. But, previously the "taskId" was used among of the command and its arguments while searching the input object in the resolveTaskToInput() function. Among of other effects, this was leading to exception throwing for the use-case like described in the ticket (combined usage of the Shell Command and CommandVariable extensions usage). This patch if doesn't fix #131, then gives a workaround for it. Specifying the "taskId" for the Shell Command calls lets the variables substitution with CommandVariable extension (using the variableSubstArgs argument).

@roussak roussak changed the title Extracted the taskId criteria while searching the input. #131 Extracted the taskId criteria while searching the input Feb 4, 2025
@MarcelRobitaille
Copy link
Collaborator

Thanks for your contribution. It looks sensible. Please update the changelog and run npm install to update the version also in the package-lock.json

@roussak roussak force-pushed the master branch 2 times, most recently from 5bfd24e to 952bbea Compare February 4, 2025 14:50
@MarcelRobitaille
Copy link
Collaborator

I know that the readme says that taskId is unique, but I know of people abusing this to share remembered data between tasks. This is very powerful when combined with ${taskId:...}.

I would recommend:

  • Showing a warning if a taskId is duplicated
  • Adding a field rememberUnder to specify an alternative taskId under which to remember the selection. Everyone using the taskId hack will have to migrate to this.

Would you like to implement that in this PR or would you like me to do it separately?

@roussak
Copy link
Author

roussak commented Feb 4, 2025

I think, this feature doesn't "fit" into this commit "by design" -- it's relates to slightly different theme. Furthermore, I work on C/C++, not TS. :)

@MarcelRobitaille
Copy link
Collaborator

That is to say I should do it?

I'm also a C++ developer professionally, and I don't use VSCode 😆

@MarcelRobitaille
Copy link
Collaborator

I implemented the first part in #136.

@roussak
Copy link
Author

roussak commented Feb 5, 2025

I'm also a C++ developer professionally, and I don't use VSCode 😆

So, what are you doing here then?.. :')

I implemented the first part in #136.

And what about this PR? Will you merge it later, after implementation the second part of your Great Plans? :)

@MarcelRobitaille
Copy link
Collaborator

@roussak Yes, I am preparing to merge your PR. I'm trying to do it carefully to avoid breaking things for people, even if that use case is an abuse of taskId. I hope I can proceed soon. I'm sorry for the delay.

@MarcelRobitaille
Copy link
Collaborator

@roussak Sorry for the delay. I finally had some time to work on this. Please rebase on master and fix the conflicts, then I'll review it.

…#131

The very presence of an "Id" in the name suggests that this entity must
be something unique. But, previously the "taskId" was used among of the
command and its arguments while searching the input object in the
resolveTaskToInput() function. Among of other effects, this was leading
to exception throwing for the use-case like described in the ticket
(combined usage of the Shell Command and CommandVariable extensions
usage). This patch if doesn't fix this issue, then gives a workaround
for it. Specifying the "taskId" for the Shell Command calls lets the
variables substitution with CommandVariable extension (using the
`variableSubstArgs` argument).
## [1.16.1] 2025-02-04

- Extracted the `taskId` criteria while searching the input. (#131)

## [Unreleased] xxxx-xx-xx
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please delete this line and update the date for 1.16.1

@@ -466,8 +466,14 @@ export class CommandHandler {
duplicateTaskIds.add(input.args.taskId);
}

if (input.args.command === this.command &&
input?.args?.taskId === taskId &&
// FIXME: Aside of the buisness-logic of the program,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be fine, shouldn't it?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not quite understand you.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You added a FIXME comment, but I don't see the problem with assigning result multiple times.

@@ -466,8 +466,14 @@ export class CommandHandler {
duplicateTaskIds.add(input.args.taskId);
}

if (input.args.command === this.command &&
input?.args?.taskId === taskId &&
// FIXME: Aside of the buisness-logic of the program,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I forgot to update the comment on 463. Could you please do that?

Copy link
Author

Choose a reason for hiding this comment

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

How?

By the way, the comment on line 463 says that we return the first match, but technically we return the last match. Of course, when we are searching by Id, the match most probably will be the only (i.e. will hide the potential problem mentioned in my FIXME).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I'd be fine with just deleting the comment. I added it because I think not everyone is familiar with generators, but now it's just an array.

We can get multiple matches if getSectionInputs("tasks", folder); (multi-workspace aware) returns the same as yield* getSectionInputs("tasks"); This is expected and fine.

@MarcelRobitaille
Copy link
Collaborator

It would be great if you could add a test case using commandvariable

@roussak
Copy link
Author

roussak commented Feb 25, 2025

It would be great if you could add a test case using commandvariable

For sure, but is there any guideline (example) for this?

@MarcelRobitaille
Copy link
Collaborator

For sure, but is there any guideline (example) for this?

The current testing situation isn't ideal (mostly because I haven't found a good way to test VSCode). You can look into src/lib/CommandHandler.test.ts for examples. You can put your tasks.json in src/test/testData/.... You also have to generate mockData.ts which is a bit annoying. You can look into the comments at the top of src/mocks/vscode.ts for this.

@roussak
Copy link
Author

roussak commented Feb 26, 2025

I see. But, probably, I will be able to do this only next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Could not find input with command" pop up while trying the commandvariable's exemple
2 participants