Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykim1 committed Jan 10, 2025
1 parent e372a9d commit 29b59e5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,10 @@ import { assertNoRpc } from '../utils';

if (platform() === 'darwin') {
test('Test if env is set', async () => {
// check if env is set, for example for bash & zsh
const { shellIntegration } = await createTerminalAndWaitForShellIntegration();
const env = shellIntegration.env;
ok(env);
// check if env has shellPath
ok(env['shellPath']);
// check if shellPath is '/bin/bash'
strictEqual(env['shellPath'], '/bin/bash');
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ export class ShellEnvDetectionCapability extends Disposable implements IShellEnv
if (!isTrusted) {
return;
}
// Clear out the current WIP env when starting single env addition.
this._env.clear();
}
setSingleEnvironmentVar(key: string, value: string | undefined, isTrusted: boolean): void {
if (!isTrusted) {
return;
}
if (key !== undefined && value !== undefined) { // Is this enough of a check? Perhaps use some method from Objects in VS Code.
if (key !== undefined && value !== undefined) {
this._env.set(key, value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
return true;
}
case VSCodeOscPt.EnvEntry: {
const arg0 = args[0]; // Key
const arg1 = args[1]; // Value
const arg2 = args[2]; // Nonce
const arg0 = args[0];
const arg1 = args[1];
const arg2 = args[2];
if (arg0 !== undefined && arg1 !== undefined) {
const env = deserializeMessage(arg1);
this._createOrGetShellEnvDetection().setSingleEnvironmentVar(arg0, env, arg2 === this._nonce);
Expand Down
48 changes: 24 additions & 24 deletions src/vs/workbench/api/common/extHostTerminalShellIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,30 @@ export class ExtHostTerminalShellIntegration extends Disposable implements IExtH
}));

// Convenient test code:
this.onDidChangeTerminalShellIntegration(e => {
console.log('*** onDidChangeTerminalShellIntegration', e.shellIntegration.env);
});
this.onDidStartTerminalShellExecution(async e => {
console.log('*** onDidStartTerminalShellExecution', e);
// new Promise<void>(r => {
// (async () => {
// for await (const d of e.execution.read()) {
// console.log('data2', d);
// }
// })();
// });
for await (const d of e.execution.read()) {
console.log('data', d);
}
});
this.onDidEndTerminalShellExecution(e => {
console.log('*** onDidEndTerminalShellExecution', e);
});
setTimeout(() => {
console.log('before executeCommand(\"echo hello\")');
Array.from(this._activeShellIntegrations.values())[0].value.executeCommand('echo hello');
console.log('after executeCommand(\"echo hello\")');
}, 4000);
// this.onDidChangeTerminalShellIntegration(e => {
// console.log('*** onDidChangeTerminalShellIntegration', e);
// });
// this.onDidStartTerminalShellExecution(async e => {
// console.log('*** onDidStartTerminalShellExecution', e);
// // new Promise<void>(r => {
// // (async () => {
// // for await (const d of e.execution.read()) {
// // console.log('data2', d);
// // }
// // })();
// // });
// for await (const d of e.execution.read()) {
// console.log('data', d);
// }
// });
// this.onDidEndTerminalShellExecution(e => {
// console.log('*** onDidEndTerminalShellExecution', e);
// });
// setTimeout(() => {
// console.log('before executeCommand(\"echo hello\")');
// Array.from(this._activeShellIntegrations.values())[0].value.executeCommand('echo hello');
// console.log('after executeCommand(\"echo hello\")');
// }, 4000);
}

public $shellIntegrationChange(instanceId: number): void {
Expand Down

0 comments on commit 29b59e5

Please sign in to comment.