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

make sure args are defined #181941

Closed
wants to merge 13 commits into from
23 changes: 15 additions & 8 deletions src/vs/platform/terminal/common/xterm/shellIntegrationAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,13 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
}

// Pass the sequence along to the capability
const [command, ...args] = data.split(';');
const commandAndArgs = data.split(';');
if (!commandAndArgs.length) {
// No command
return false;
}
const command = commandAndArgs[0];
const args: string[] = commandAndArgs.length > 1 ? commandAndArgs.slice(1) : [];
switch (command) {
case VSCodeOscPt.PromptStart:
this._createOrGetCommandDetection(this._terminal).handlePromptStart();
Expand All @@ -333,13 +339,11 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
return true;
}
case VSCodeOscPt.CommandLine: {
let commandLine: string;
if (args.length >= 1 || args.length <= 2) {
commandLine = deserializeMessage(args[0]);
} else {
commandLine = '';
const commandLine = deserializeMessage(args[0]);
const isTrusted = args[1] === this._nonce;
if (commandLine) {
this._createOrGetCommandDetection(this._terminal).setCommandLine(commandLine, isTrusted);
}
this._createOrGetCommandDetection(this._terminal).setCommandLine(commandLine, args[1] === this._nonce);
return true;
}
case VSCodeOscPt.ContinuationStart: {
Expand All @@ -359,7 +363,10 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
return true;
}
case VSCodeOscPt.Property: {
const deserialized = args.length ? deserializeMessage(args[0]) : '';
const deserialized = args.length === 0 ? undefined : deserializeMessage(args[0]);
if (!deserialized) {
return true;
}
const { key, value } = parseKeyValueAssignment(deserialized);
if (value === undefined) {
return true;
Expand Down