Skip to content
Merged
1 change: 1 addition & 0 deletions news/2 Fixes/15522.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When activating environment, creating new Integrated Terminal doesn't take selected workspace into account. (Thanks [Vidushi Gupta](https://github.com/Vidushi-Gupta) for the contribution)
19 changes: 13 additions & 6 deletions src/client/terminals/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import { inject, injectable } from 'inversify';
import { Terminal } from 'vscode';
import { Terminal, Uri } from 'vscode';
import { IActiveResourceService, ITerminalManager } from '../common/application/types';
import { ITerminalActivator } from '../common/terminal/types';
import { IDisposable, IDisposableRegistry } from '../common/types';
Expand All @@ -17,10 +17,12 @@ export class TerminalAutoActivation implements ITerminalAutoActivation {
private readonly terminalsNotToAutoActivate = new WeakSet<Terminal>();

constructor(
@inject(ITerminalManager) private readonly terminalManager: ITerminalManager,
@inject(ITerminalManager)
private readonly terminalManager: ITerminalManager,
@inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry,
@inject(ITerminalActivator) private readonly activator: ITerminalActivator,
@inject(IActiveResourceService) private readonly activeResourceService: IActiveResourceService,
@inject(IActiveResourceService)
private readonly activeResourceService: IActiveResourceService,
) {
disposableRegistry.push(this);
}
Expand Down Expand Up @@ -50,10 +52,15 @@ export class TerminalAutoActivation implements ITerminalAutoActivation {
if ('hideFromUser' in terminal.creationOptions && terminal.creationOptions.hideFromUser) {
return;
}
// If we have just one workspace, then pass that as the resource.
// Until upstream VSC issue is resolved https://github.com/Microsoft/vscode/issues/63052.

const cwd =
'cwd' in terminal.creationOptions
? terminal.creationOptions.cwd
: this.activeResourceService.getActiveResource();
const resource = typeof cwd === 'string' ? Uri.file(cwd) : cwd;
Comment thread
karthiknadig marked this conversation as resolved.

await this.activator.activateEnvironmentInTerminal(terminal, {
resource: this.activeResourceService.getActiveResource(),
resource,
});
}
}