-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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] ShellExecution update with undefined command #15047
Conversation
fix eclipse-theia#14940 Contributed on behalf of STMicroelectronics Signed-off-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
* integration script is misbehaving) or the shell reported a command started before the command | ||
* finished (eg. a sub-shell was opened). Generally this should not happen, depending on the use | ||
* case, it may be best to treat this as a failure. | ||
* When this is `undefined` it can mean several things: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just drive-by fixes, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the comments were changed in equivalent file in vscode, but these are only better explanation on the API behavior.
@@ -13197,12 +13203,12 @@ export module '@theia/plugin' { | |||
/** | |||
* The shell command. Is `undefined` if created with a full command line. | |||
*/ | |||
command?: string | ShellQuotedString; | |||
command: string | ShellQuotedString | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read this change correctly, it does not really change the usage of the class in any way, right? it probably would force literals to include a value for "command" if it was an interface, but not for a class.
That said, if I look at the implementation of ShellExecution
in types-impl.ts
, I see this:
set commandLine(value: string) {
if (typeof value !== 'string') {
throw illegalArgument('commandLine');
}
So it throws an exception if I assign undefined
. But that's not consistent with the typing. What's the reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsmaeder, basically, for the shell execution, we are supposed to have either commandLine set to a valid string, or the command and eventually args.
The check in the types-impl is redundant with the one in the constructor. I would also not expect the shell execution to be changed at runtime. In case we still want to change at runtime, this may be done using an atomic change between command line and command + args, to ensure only one group is defined at a time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a command
value, shouldn't we be checking that we don't have a commandLine
value? Because we're not supposed to have both, right? Anyway, why aren't we respecting the interface and complaining at execution time that the user set something unusable.
I would also not expect the shell execution to be changed at runtime.
But the API allows it, so people are going to do it 🤷 This check might break exensions that do
execution.command = undefined;
execution.commandLine = 'ls -ls`;
which would work perfectly fine otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I understand you, we should allow undefined
in the setCommand, setCommandLine (and setArgs), remove the checks done on the values, and allow the getters to return also undefined
in types-impl?
Otherwise, we would have issues with the first line
execution.command = undefined;
both commandLine and command would be undefined at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The typing says you can assign undefined to command
, so if the implementation is not allowing that, there needs to be a reasons for that. If we try to not allow both command
and commandLine
, we would have to have a different check. It seems the checks are coming from the extHostTypes.ts
in VS Code. But those checks would still allow for both command
and commandLine
to be set. So we're bug-compatible with VS Code in this respect, but it is still wrong and it still bugs me 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a typing-only change that should not affect clients and the implementation, albeit bogus, is compatible with VS Code and has been like that for years.
What it does
Adds in the API the possibility to have an undefined command or args for the shellexecution. This was already supported by the implementation but not clearly defined in the API.
How to test
1+1
.issue14940.mp4
Follow-ups
No follow ups
Breaking changes
Attribution
Contributed on behalf of STMicroelectronics
Review checklist
Reminder for reviewers