Skip to content

Commit b4f19ae

Browse files
Creating new Integrated Terminal doesn't take selected workspace into account when activating environment (#17595)
* Worked on issue #15522 * worked on #15522 issue * added #15522 issue fix and contributor name * Impored Uri from VSCode * imported Uri correctly * imported Uri correctly * used short hand property on line 61 * formatted document using prettier * formatted code using prettier * formatted code using prettier * updated formatting of the document used 4 tab spaces in prettier * Fix formatting. Co-authored-by: Karthik Nadig <[email protected]>
1 parent 5a1edb7 commit b4f19ae

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

news/2 Fixes/15522.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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)

src/client/terminals/activation.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

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

1919
constructor(
20-
@inject(ITerminalManager) private readonly terminalManager: ITerminalManager,
20+
@inject(ITerminalManager)
21+
private readonly terminalManager: ITerminalManager,
2122
@inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry,
2223
@inject(ITerminalActivator) private readonly activator: ITerminalActivator,
23-
@inject(IActiveResourceService) private readonly activeResourceService: IActiveResourceService,
24+
@inject(IActiveResourceService)
25+
private readonly activeResourceService: IActiveResourceService,
2426
) {
2527
disposableRegistry.push(this);
2628
}
@@ -50,10 +52,15 @@ export class TerminalAutoActivation implements ITerminalAutoActivation {
5052
if ('hideFromUser' in terminal.creationOptions && terminal.creationOptions.hideFromUser) {
5153
return;
5254
}
53-
// If we have just one workspace, then pass that as the resource.
54-
// Until upstream VSC issue is resolved https://github.com/Microsoft/vscode/issues/63052.
55+
56+
const cwd =
57+
'cwd' in terminal.creationOptions
58+
? terminal.creationOptions.cwd
59+
: this.activeResourceService.getActiveResource();
60+
const resource = typeof cwd === 'string' ? Uri.file(cwd) : cwd;
61+
5562
await this.activator.activateEnvironmentInTerminal(terminal, {
56-
resource: this.activeResourceService.getActiveResource(),
63+
resource,
5764
});
5865
}
5966
}

0 commit comments

Comments
 (0)