Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5c1a185

Browse filesBrowse files
Kartik Rajanthonykim1
authored andcommitted
Do not run commands to check whether shell integration is working (#22850)
Closes #22774 closes #22743
1 parent a0b893c commit 5c1a185
Copy full SHA for 5c1a185

File tree

Expand file treeCollapse file tree

1 file changed

+28
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-0
lines changed

‎src/client/terminals/envCollectionActivation/shellIntegrationService.ts

Copy file name to clipboardExpand all lines: src/client/terminals/envCollectionActivation/shellIntegrationService.ts
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { injectable, inject } from 'inversify';
55
import { IApplicationShell, ITerminalManager, IWorkspaceService } from '../../common/application/types';
66
import { identifyShellFromShellPath } from '../../common/terminal/shellDetectors/baseShellDetector';
77
import { TerminalShellType } from '../../common/terminal/types';
8+
import { IPersistentStateFactory } from '../../common/types';
89
import { createDeferred, sleep } from '../../common/utils/async';
910
import { cache } from '../../common/utils/decorators';
1011
import { traceError, traceInfo, traceVerbose } from '../../logging';
@@ -22,12 +23,22 @@ const ShellIntegrationShells = [
2223
TerminalShellType.fish,
2324
];
2425

26+
export const isShellIntegrationWorkingKey = 'SHELL_INTEGRATION_WORKING_KEY';
27+
2528
@injectable()
2629
export class ShellIntegrationService implements IShellIntegrationService {
30+
/**
31+
* It seems to have a couple of issues:
32+
* * Ends up cluterring terminal history
33+
* * Does not work for hidden terminals: https://github.com/microsoft/vscode/issues/199611
34+
*/
35+
private readonly USE_COMMAND_APPROACH = false;
36+
2737
constructor(
2838
@inject(ITerminalManager) private readonly terminalManager: ITerminalManager,
2939
@inject(IApplicationShell) private readonly appShell: IApplicationShell,
3040
@inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService,
41+
@inject(IPersistentStateFactory) private readonly persistentStateFactory: IPersistentStateFactory,
3142
) {}
3243

3344
public async isWorking(shell: string): Promise<boolean> {
@@ -50,6 +61,23 @@ export class ShellIntegrationService implements IShellIntegrationService {
5061
if (!isSupposedToWork) {
5162
return false;
5263
}
64+
if (!this.USE_COMMAND_APPROACH) {
65+
// For now, based on problems with using the command approach, assume it always works.
66+
return true;
67+
}
68+
const key = `${isShellIntegrationWorkingKey}_${shellType}`;
69+
const persistedResult = this.persistentStateFactory.createGlobalPersistentState<boolean>(key);
70+
if (persistedResult.value !== undefined) {
71+
return persistedResult.value;
72+
}
73+
const result = await this.checkIfWorkingByRunningCommand(shell);
74+
// Persist result to storage to avoid running commands unncecessary.
75+
await persistedResult.updateValue(result);
76+
return result;
77+
}
78+
79+
private async checkIfWorkingByRunningCommand(shell: string): Promise<boolean> {
80+
const shellType = identifyShellFromShellPath(shell);
5381
const deferred = createDeferred<void>();
5482
const timestamp = new Date().getTime();
5583
const name = `Python ${timestamp}`;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.