@@ -16,7 +16,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
1616import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
1717import { IFileService } from 'vs/platform/files/common/files' ;
1818import { TerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminalInstance' ;
19- import { ITerminalService , ITerminalInstance , ITerminalTab } from 'vs/workbench/contrib/terminal/browser/terminal' ;
19+ import { ITerminalService , ITerminalInstance , ITerminalTab , TerminalShellType , WindowsShellType } from 'vs/workbench/contrib/terminal/browser/terminal' ;
2020import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService' ;
2121import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper' ;
2222import { IQuickInputService , IQuickPickItem , IPickOptions } from 'vs/platform/quickinput/common/quickInput' ;
@@ -504,7 +504,7 @@ export class TerminalService implements ITerminalService {
504504 } ) ;
505505 }
506506
507- public preparePathForTerminalAsync ( originalPath : string , executable : string , title : string ) : Promise < string > {
507+ public preparePathForTerminalAsync ( originalPath : string , executable : string , title : string , shellType : TerminalShellType ) : Promise < string > {
508508 return new Promise < string > ( c => {
509509 if ( ! executable ) {
510510 c ( originalPath ) ;
@@ -527,18 +527,41 @@ export class TerminalService implements ITerminalService {
527527 if ( isWindows ) {
528528 // 17063 is the build number where wsl path was introduced.
529529 // Update Windows uriPath to be executed in WSL.
530- const lowerExecutable = executable . toLowerCase ( ) ;
531- if ( this . _terminalNativeService . getWindowsBuildNumber ( ) >= 17063 &&
532- ( lowerExecutable . indexOf ( 'wsl' ) !== - 1 || ( lowerExecutable . indexOf ( 'bash.exe' ) !== - 1 && lowerExecutable . toLowerCase ( ) . indexOf ( 'git' ) === - 1 ) ) ) {
533- c ( this . _terminalNativeService . getWslPath ( originalPath ) ) ;
534- return ;
535- } else if ( hasSpace ) {
536- c ( '"' + originalPath + '"' ) ;
530+ if ( shellType !== undefined ) {
531+ if ( shellType === WindowsShellType . GitBash ) {
532+ c ( originalPath . replace ( / \\ / g, '/' ) ) ;
533+ return ;
534+ }
535+ else if ( shellType === WindowsShellType . Wsl ) {
536+ if ( this . _terminalNativeService . getWindowsBuildNumber ( ) >= 17063 ) {
537+ c ( this . _terminalNativeService . getWslPath ( originalPath ) ) ;
538+ } else {
539+ c ( originalPath . replace ( / \\ / g, '/' ) ) ;
540+ }
541+ return ;
542+ }
543+
544+ if ( hasSpace ) {
545+ c ( '"' + originalPath + '"' ) ;
546+ } else {
547+ c ( originalPath ) ;
548+ }
537549 } else {
538- c ( originalPath ) ;
550+ const lowerExecutable = executable . toLowerCase ( ) ;
551+ if ( this . _terminalNativeService . getWindowsBuildNumber ( ) >= 17063 &&
552+ ( lowerExecutable . indexOf ( 'wsl' ) !== - 1 || ( lowerExecutable . indexOf ( 'bash.exe' ) !== - 1 && lowerExecutable . toLowerCase ( ) . indexOf ( 'git' ) === - 1 ) ) ) {
553+ c ( this . _terminalNativeService . getWslPath ( originalPath ) ) ;
554+ return ;
555+ } else if ( hasSpace ) {
556+ c ( '"' + originalPath + '"' ) ;
557+ } else {
558+ c ( originalPath ) ;
559+ }
539560 }
561+
540562 return ;
541563 }
564+
542565 c ( escapeNonWindowsPath ( originalPath ) ) ;
543566 } ) ;
544567 }
0 commit comments