@@ -2,60 +2,27 @@ import { l10n } from 'vscode';
22import { executeCommand } from '../../common/command.api' ;
33import { Common , ShellStartupActivationStrings } from '../../common/localize' ;
44import { traceInfo , traceVerbose } from '../../common/logging' ;
5+ import { isWindows } from '../../common/utils/platformUtils' ;
56import { showErrorMessage , showInformationMessage } from '../../common/window.apis' ;
7+ import { ShellConstants } from '../common/shellConstants' ;
68import { ShellScriptEditState , ShellStartupScriptProvider } from './shells/startupProvider' ;
79import { getAutoActivationType , setAutoActivationType } from './utils' ;
810
9- export async function handleSettingUpShellProfile ( provider : ShellStartupScriptProvider ) : Promise < boolean > {
10- const response = await showInformationMessage (
11- l10n . t (
12- 'To use "{0}" activation, the shell profile for "{1}" shell needs to be set up. Do you want to set it up now?' ,
13- 'shellStartup' ,
14- provider . shellType ,
15- ) ,
16- { modal : true } ,
17- Common . yes ,
18- Common . no ,
19- ) ;
20- if ( response === Common . yes ) {
21- traceVerbose ( `User chose to set up shell profile for ${ provider . shellType } shell` ) ;
22- const state = await provider . setupScripts ( ) ;
23-
24- if ( state === ShellScriptEditState . Edited ) {
25- setImmediate ( async ( ) => {
26- await showInformationMessage (
27- l10n . t (
28- 'Shell profile for "{0}" shell has been set up successfully. Extension will use shell startup activation next time a new terminal is created.' ,
29- provider . shellType ,
30- ) ,
31- Common . ok ,
32- ) ;
33- } ) ;
11+ function getProviders ( shellTypes : Set < string > , providers : ShellStartupScriptProvider [ ] ) : ShellStartupScriptProvider [ ] {
12+ return providers . filter ( ( provider ) => {
13+ if ( isWindows ( ) && shellTypes . has ( ShellConstants . PWSH ) && provider . shellType === 'powershell' ) {
3414 return true ;
35- } else if ( state === ShellScriptEditState . NotEdited || state === ShellScriptEditState . NotInstalled ) {
36- setImmediate ( async ( ) => {
37- const button = await showErrorMessage (
38- l10n . t (
39- 'Failed to set up shell profile for "{0}" shell. Please check the output panel for more details.' ,
40- provider . shellType ,
41- ) ,
42- Common . viewLogs ,
43- ) ;
44- if ( button === Common . viewLogs ) {
45- await executeCommand ( 'python-envs.viewLogs' ) ;
46- }
47- } ) ;
4815 }
49- } else {
50- traceVerbose ( `User chose not to set up shell profile for ${ provider . shellType } shell` ) ;
51- }
52- return false ;
16+ return shellTypes . has ( provider . shellType ) ;
17+ } ) ;
5318}
5419
55- export async function handleSettingUpShellProfileMultiple (
56- providers : ShellStartupScriptProvider [ ] ,
20+ export async function handleSettingUpShellProfile (
21+ shellTypes : Set < string > ,
22+ allProviders : ShellStartupScriptProvider [ ] ,
5723 callback : ( provider : ShellStartupScriptProvider , result : boolean ) => void ,
5824) : Promise < void > {
25+ const providers = getProviders ( shellTypes , allProviders ) ;
5926 const shells = providers . map ( ( p ) => p . shellType ) . join ( ', ' ) ;
6027 const response = await showInformationMessage (
6128 l10n . t (
@@ -95,8 +62,8 @@ export async function handleSettingUpShellProfileMultiple(
9562 }
9663}
9764
98- export async function cleanupStartupScripts ( shellStartupProviders : ShellStartupScriptProvider [ ] ) : Promise < void > {
99- await Promise . all ( shellStartupProviders . map ( ( provider ) => provider . teardownScripts ( ) ) ) ;
65+ export async function cleanupStartupScripts ( allProviders : ShellStartupScriptProvider [ ] ) : Promise < void > {
66+ await Promise . all ( allProviders . map ( ( provider ) => provider . teardownScripts ( ) ) ) ;
10067 if ( getAutoActivationType ( ) === 'shellStartup' ) {
10168 setAutoActivationType ( 'command' ) ;
10269 traceInfo (
0 commit comments