@@ -297,29 +297,38 @@ class RubyDebugSession extends DebugSession {
297297 return subPath && ! subPath . startsWith ( '..' ) && ! path . isAbsolute ( subPath ) ;
298298 }
299299
300- private getPathImplementation ( absolutePath : string ) : any {
301- return path && path . posix . isAbsolute ( absolutePath ) ? path . posix : path . win32 ;
300+ private getPathImplementation ( pathToCheck : string ) : any {
301+ if ( pathToCheck ) {
302+ if ( pathToCheck . indexOf ( path . posix . sep ) >= 0 ) {
303+ return path . posix ;
304+ } else if ( pathToCheck . indexOf ( path . win32 . sep ) >= 0 ) {
305+ return path . win32 ;
306+ }
307+ }
308+
309+ return path ;
302310 }
303311
304312 protected convertClientPathToDebugger ( localPath : string ) : string {
305313 if ( this . debugMode === Mode . launch ) {
306314 return localPath ;
307315 }
308316
309- let relativeLocalPath = path . relative ( this . requestArguments . cwd , localPath )
317+ let relativeLocalPath = path . relative ( this . requestArguments . cwd , localPath ) ;
310318
311319 if ( ! this . isSubPath ( relativeLocalPath ) ) {
312320 return localPath ;
313321 }
314322
315- let remotePathImplementation = this . getPathImplementation ( this . requestArguments . remoteWorkspaceRoot ) ;
323+ let remoteWorkspaceRoot =
324+ this . requestArguments . remoteWorkspaceRoot || this . requestArguments . cwd ;
325+
326+ let remotePathImplementation = this . getPathImplementation ( remoteWorkspaceRoot ) ;
316327 let localPathImplementation = this . getPathImplementation ( this . requestArguments . cwd ) ;
317328
318329 let relativePath = remotePathImplementation . join . apply (
319330 null ,
320- [ this . requestArguments . remoteWorkspaceRoot ] . concat (
321- relativeLocalPath . split ( localPathImplementation . sep )
322- )
331+ [ remoteWorkspaceRoot ] . concat ( relativeLocalPath . split ( localPathImplementation . sep ) )
323332 ) ;
324333
325334 return relativePath ;
@@ -330,20 +339,22 @@ class RubyDebugSession extends DebugSession {
330339 return serverPath ;
331340 }
332341
333- let remotePathImplementation = this . getPathImplementation ( this . requestArguments . remoteWorkspaceRoot ) ;
342+ let remoteWorkspaceRoot =
343+ this . requestArguments . remoteWorkspaceRoot || this . requestArguments . cwd ;
344+
345+ let remotePathImplementation = this . getPathImplementation ( remoteWorkspaceRoot ) ;
334346 let localPathImplementation = this . getPathImplementation ( this . requestArguments . cwd ) ;
335347
336- let relativeRemotePath = remotePathImplementation . relative ( this . requestArguments . remoteWorkspaceRoot , serverPath )
348+ let relativeRemotePath = remotePathImplementation . relative ( remoteWorkspaceRoot , serverPath ) ;
349+
337350
338351 if ( ! this . isSubPath ( relativeRemotePath ) ) {
339352 return serverPath ;
340353 }
341354
342355 let relativePath = localPathImplementation . join . apply (
343356 null ,
344- [ this . requestArguments . cwd ] . concat (
345- relativeRemotePath . split ( remotePathImplementation . sep )
346- )
357+ [ this . requestArguments . cwd ] . concat ( relativeRemotePath . split ( remotePathImplementation . sep ) )
347358 ) ;
348359
349360 return relativePath ;
0 commit comments