@@ -369,26 +369,14 @@ export class PythonDebugger extends DebugSession {
369369 /** converts the remote path to local path */
370370 protected convertDebuggerPathToClient ( remotePath : string ) : string {
371371 if ( this . attachArgs && this . attachArgs . localRoot && this . attachArgs . remoteRoot ) {
372- let pathRelativeToSourceRoot = path . relative ( this . attachArgs . remoteRoot , remotePath ) ;
373- let clientPath = path . resolve ( this . attachArgs . localRoot , pathRelativeToSourceRoot ) ;
374- if ( validatePathSync ( clientPath ) ) {
375- return clientPath ;
376- }
377- else {
378- // It is possible we're dealing with cross platform debugging
379- // If so, then path.relative won't work :(
380- if ( remotePath . toUpperCase ( ) . startsWith ( this . attachArgs . remoteRoot . toUpperCase ( ) ) ) {
381- pathRelativeToSourceRoot = remotePath . substring ( this . attachArgs . remoteRoot . length ) . trim ( ) ;
382- } else {
383- // get the part of the path that is relative to the source root
384- pathRelativeToSourceRoot = path . relative ( this . attachArgs . remoteRoot , remotePath ) . trim ( ) ;
385- }
386- if ( pathRelativeToSourceRoot . startsWith ( path . sep ) ) {
387- pathRelativeToSourceRoot = pathRelativeToSourceRoot . substring ( 1 ) ;
388- }
389- // resolve from the local source root
390- return path . resolve ( this . attachArgs . localRoot , pathRelativeToSourceRoot ) ;
372+ let path2 = path . win32 ;
373+ if ( this . attachArgs . remoteRoot . indexOf ( '/' ) != - 1 ) {
374+ path2 = path . posix ;
391375 }
376+ let pathRelativeToSourceRoot = path2 . relative ( this . attachArgs . remoteRoot , remotePath ) ;
377+ // resolve from the local source root
378+ let clientPath = path . resolve ( this . attachArgs . localRoot , pathRelativeToSourceRoot ) ;
379+ return clientPath ;
392380 } else {
393381 return remotePath ;
394382 }
@@ -399,7 +387,11 @@ export class PythonDebugger extends DebugSession {
399387 // get the part of the path that is relative to the client root
400388 const pathRelativeToClientRoot = path . relative ( this . attachArgs . localRoot , clientPath ) ;
401389 // resolve from the remote source root
402- return path . resolve ( this . attachArgs . remoteRoot , pathRelativeToClientRoot ) ;
390+ let path2 = path . win32 ;
391+ if ( this . attachArgs . remoteRoot . indexOf ( '/' ) != - 1 ) {
392+ path2 = path . posix ;
393+ }
394+ return path2 . resolve ( this . attachArgs . remoteRoot , pathRelativeToClientRoot ) ;
403395 } else {
404396 return clientPath ;
405397 }
0 commit comments