@@ -63,34 +63,55 @@ public string ConvertDebuggerPathToClient(string path)
6363 }
6464 }
6565
66- public string ConvertClientPathToDebugger ( string clientPath )
67- {
68- if ( clientPath == null ) {
69- return null ;
70- }
66+ public string ConvertClientPathToDebugger ( string clientPath )
67+ {
68+ if ( clientPath == null ) {
69+ return null ;
70+ }
7171
72- if ( DebuggerPathsAreUri ) {
73- if ( ClientPathsAreUri ) {
74- return clientPath ;
75- }
76- else {
77- var uri = new System . Uri ( clientPath ) ;
78- return uri . AbsoluteUri ;
79- }
80- }
81- else {
82- if ( ClientPathsAreUri ) {
83- if ( Uri . IsWellFormedUriString ( clientPath , UriKind . Absolute ) ) {
84- Uri uri = new Uri ( clientPath ) ;
85- return uri . LocalPath ;
86- }
87- Console . Error . WriteLine ( "path not well formed: '{0}'" , clientPath ) ;
88- return null ;
89- }
90- else {
91- return clientPath ;
92- }
93- }
94- }
72+ string hostWorkspace = Environment . GetEnvironmentVariable ( "OSCRIPT_DEBUGWORKSPACE_HOST" ) ;
73+ string remoteWorkspace = Environment . GetEnvironmentVariable ( "OSCRIPT_DEBUGWORKSPACE_REMOTE" ) ;
74+
75+ if ( ! string . IsNullOrEmpty ( hostWorkspace ) && ! string . IsNullOrEmpty ( remoteWorkspace ) )
76+ {
77+ string normalizedClientPath = clientPath . Replace ( '/' , '\\ ' ) ;
78+ string normalizedHostWorkspace = hostWorkspace . Replace ( '/' , '\\ ' ) ;
79+
80+ if ( normalizedClientPath . StartsWith ( normalizedHostWorkspace , StringComparison . OrdinalIgnoreCase ) )
81+ {
82+ string relativePath = normalizedClientPath . Substring ( normalizedHostWorkspace . Length ) ;
83+
84+ string normalizedRemote = remoteWorkspace . Replace ( '\\ ' , '/' ) ;
85+ string normalizedRelative = relativePath . Replace ( '\\ ' , '/' ) ;
86+
87+ string result = normalizedRemote . TrimEnd ( '/' ) + "/" + normalizedRelative . TrimStart ( '/' ) ;
88+
89+ return result ;
90+ }
91+ }
92+
93+ if ( DebuggerPathsAreUri ) {
94+ if ( ClientPathsAreUri ) {
95+ return clientPath ;
96+ }
97+ else {
98+ var uri = new System . Uri ( clientPath ) ;
99+ return uri . AbsoluteUri ;
100+ }
101+ }
102+ else {
103+ if ( ClientPathsAreUri ) {
104+ if ( Uri . IsWellFormedUriString ( clientPath , UriKind . Absolute ) ) {
105+ Uri uri = new Uri ( clientPath ) ;
106+ return uri . LocalPath ;
107+ }
108+ Console . Error . WriteLine ( "path not well formed: '{0}'" , clientPath ) ;
109+ return null ;
110+ }
111+ else {
112+ return clientPath ;
113+ }
114+ }
115+ }
95116 }
96117}
0 commit comments