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

Test: getting Env from new proposed shell integration api #24693

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/client/common/terminal/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { inject, injectable } from 'inversify';
import { CancellationToken, Disposable, Event, EventEmitter, Terminal, TerminalShellExecution } from 'vscode';
import { window, CancellationToken, Disposable, Event, EventEmitter, Terminal, TerminalShellExecution } from 'vscode';
import '../../common/extensions';
import { IInterpreterService } from '../../interpreter/contracts';
import { IServiceContainer } from '../../ioc/types';
Expand Down Expand Up @@ -88,6 +88,18 @@ export class TerminalService implements ITerminalService, Disposable {
terminal.show(true);
}

window.onDidChangeTerminalState((e) => {
const ourTerminalState = e.state;
console.log(ourTerminalState);
traceVerbose('Printing our terminal state from service.ts', ourTerminalState);

const ourStateTypeless = (ourTerminalState as unknown) as { isInteractedWith: any; shellType: any };
const ourState = ourStateTypeless.isInteractedWith;
traceVerbose('Printing our terminal state from service.ts', ourState);
const ourShellType = ourStateTypeless.shellType;
traceVerbose('Printing our terminal state from service.ts', ourShellType);
traceVerbose('finished printing our terminal state');
});
// If terminal was just launched, wait some time for shell integration to onDidChangeShellIntegration.
if (!terminal.shellIntegration && this._terminalFirstLaunched) {
this._terminalFirstLaunched = false;
Expand All @@ -96,6 +108,12 @@ export class TerminalService implements ITerminalService, Disposable {
clearTimeout(timer);
disposable.dispose();
resolve(true);

// const shellIntegration = (terminal.shellIntegration as unknown) as { env: any };
// const tempEnv = shellIntegration.env;
// console.log(tempEnv);
// traceVerbose('Printing temp env from service.ts in terminal1', tempEnv);
// traceVerbose('finished printing temp env ');
});
const TIMEOUT_DURATION = 500;
const timer = setTimeout(() => {
Expand All @@ -114,7 +132,13 @@ export class TerminalService implements ITerminalService, Disposable {
return undefined;
} else if (terminal.shellIntegration) {
const execution = terminal.shellIntegration.executeCommand(commandLine);
traceVerbose(`Shell Integration is enabled, executeCommand: ${commandLine}`);

// const shellIntegration = (terminal.shellIntegration as unknown) as { env: any };
// const tempEnv = shellIntegration.env;
// console.log(tempEnv);
// traceVerbose('Printing temp env from service.ts in terminal2', tempEnv);
// traceVerbose('finished printing temp env ');
// traceVerbose(`Shell Integration is enabled, executeCommand: ${commandLine}`);
return execution;
} else {
terminal.sendText(commandLine);
Expand Down
15 changes: 15 additions & 0 deletions src/client/extensionActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { registerReplCommands, registerReplExecuteOnEnter, registerStartNativeRe
import { registerTriggerForTerminalREPL } from './terminals/codeExecution/terminalReplWatcher';
import { registerPythonStartup } from './terminals/pythonStartup';
import { registerPixiFeatures } from './pythonEnvironments/common/environmentManagers/pixi';
import { traceVerbose } from './logging';

export async function activateComponents(
// `ext` is passed to any extra activation funcs.
Expand Down Expand Up @@ -115,6 +116,20 @@ export function activateFeatures(ext: ExtensionState, _components: Components):
registerStartNativeReplCommand(ext.disposables, interpreterService);
registerReplCommands(ext.disposables, interpreterService, executionHelper, commandManager);
registerReplExecuteOnEnter(ext.disposables, interpreterService, commandManager);

window.onDidChangeTerminalState((e) => {
const ourTerminalState = e.state;
console.log(ourTerminalState);
traceVerbose('Printing our terminal state from service.ts', ourTerminalState);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const ourStateTypeless = (ourTerminalState as unknown) as { isInteractedWith: any; shellType: any };
const ourState = ourStateTypeless.isInteractedWith;
traceVerbose('Printing our terminal state from service.ts', ourState);
const ourShellType = ourStateTypeless.shellType;
traceVerbose('Printing our terminal state from service.ts', ourShellType);
traceVerbose('finished printing our terminal state');
});
}

/// //////////////////////////
Expand Down
Loading