@@ -8,6 +8,7 @@ import { CancellationToken, Uri, WorkspaceFolder } from 'vscode';
88import { IDocumentManager , IWorkspaceService } from '../../../../common/application/types' ;
99import { IPlatformService } from '../../../../common/platform/types' ;
1010import { IConfigurationService } from '../../../../common/types' ;
11+ import { SystemVariables } from '../../../../common/variables/systemVariables' ;
1112import { AttachRequestArguments , DebugOptions } from '../../../types' ;
1213import { BaseConfigurationResolver } from './base' ;
1314
@@ -94,18 +95,33 @@ export class AttachConfigurationResolver extends BaseConfigurationResolver<Attac
9495 }
9596 // If attaching to local host, then always map local root and remote roots.
9697 if ( workspaceFolder && debugConfiguration . host &&
97- debugConfiguration . pathMappings ! . length === 0 &&
9898 [ 'LOCALHOST' , '127.0.0.1' , '::1' ] . indexOf ( debugConfiguration . host . toUpperCase ( ) ) >= 0 ) {
99- // If on Windows, lowercase the drive letter for path mappings.
100- let localRoot = workspaceFolder . fsPath ;
101- if ( this . platformService . isWindows && localRoot . match ( / ^ [ A - Z ] : / ) ) {
102- localRoot = `${ localRoot [ 0 ] . toLowerCase ( ) } ${ localRoot . substr ( 1 ) } ` ;
103- }
104-
105- debugConfiguration . pathMappings ! . push ( {
106- localRoot,
107- remoteRoot : workspaceFolder . fsPath
108- } ) ;
99+ let configPathMappings ;
100+ if ( debugConfiguration . pathMappings ! . length === 0 ) {
101+ configPathMappings = [ {
102+ localRoot : workspaceFolder . fsPath ,
103+ remoteRoot : workspaceFolder . fsPath
104+ } ] ;
105+ } else {
106+ // Expand ${workspaceFolder} variable first if necessary.
107+ const systemVariables = new SystemVariables ( workspaceFolder . fsPath ) ;
108+ configPathMappings = debugConfiguration . pathMappings . map ( ( { localRoot : mappedLocalRoot , remoteRoot } ) => ( {
109+ localRoot : systemVariables . resolveAny ( mappedLocalRoot ) ,
110+ remoteRoot
111+ } ) ) ;
112+ }
113+ // If on Windows, lowercase the drive letter for path mappings.
114+ let pathMappings = configPathMappings ;
115+ if ( this . platformService . isWindows ) {
116+ pathMappings = configPathMappings . map ( ( { localRoot : windowsLocalRoot , remoteRoot } ) => {
117+ let localRoot = windowsLocalRoot ;
118+ if ( windowsLocalRoot . match ( / ^ [ A - Z ] : / ) ) {
119+ localRoot = `${ windowsLocalRoot [ 0 ] . toLowerCase ( ) } ${ windowsLocalRoot . substr ( 1 ) } ` ;
120+ }
121+ return { localRoot, remoteRoot } ;
122+ } ) ;
123+ }
124+ debugConfiguration . pathMappings = pathMappings ;
109125 }
110126 this . sendTelemetry ( 'attach' , debugConfiguration ) ;
111127 }
0 commit comments