Skip to content

Commit 33671e4

Browse files
authored
Merge pull request microsoft#165579 from rwe/shellint-no-decode-iterm2
shellIntegrationAddon.ts: only decode messages for VSCodeOScPt, not iTerm2
2 parents 4ed4cf6 + 9eb2de7 commit 33671e4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/vs/platform/terminal/common/xterm/shellIntegrationAddon.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
353353
return true;
354354
}
355355
case VSCodeOscPt.Property: {
356-
const { key, value } = parseKeyValueAssignment(args[0]);
356+
const deserialized = args.length ? deserializeMessage(args[0]) : '';
357+
const { key, value } = parseKeyValueAssignment(deserialized);
357358
if (value === undefined) {
358359
return true;
359360
}
@@ -402,6 +403,8 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
402403
}
403404
default: {
404405
// Checking for known `<key>=<value>` pairs.
406+
// Note that unlike `VSCodeOscPt.Property`, iTerm2 does not interpret backslash or hex-escape sequences.
407+
// See: https://github.com/gnachman/iTerm2/blob/bb0882332cec5196e4de4a4225978d746e935279/sources/VT100Terminal.m#L2089-L2105
405408
const { key, value } = parseKeyValueAssignment(command);
406409

407410
if (value === undefined) {
@@ -523,14 +526,13 @@ export function deserializeMessage(message: string): string {
523526
}
524527

525528
export function parseKeyValueAssignment(message: string): { key: string; value: string | undefined } {
526-
const deserialized = deserializeMessage(message);
527-
const separatorIndex = deserialized.indexOf('=');
529+
const separatorIndex = message.indexOf('=');
528530
if (separatorIndex === -1) {
529-
return { key: deserialized, value: undefined }; // No '=' was found.
531+
return { key: message, value: undefined }; // No '=' was found.
530532
}
531533
return {
532-
key: deserialized.substring(0, separatorIndex),
533-
value: deserialized.substring(1 + separatorIndex)
534+
key: message.substring(0, separatorIndex),
535+
value: message.substring(1 + separatorIndex)
534536
};
535537
}
536538

0 commit comments

Comments
 (0)