From 3096e48a87215c41afd4c3949975af8f916e38a6 Mon Sep 17 00:00:00 2001 From: hnioche Date: Thu, 9 May 2019 08:58:04 +0100 Subject: [PATCH 1/6] Use a more accurate way to guess the path OS --- src/debugger/main.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/debugger/main.ts b/src/debugger/main.ts index 5857372a3..707bb9b43 100644 --- a/src/debugger/main.ts +++ b/src/debugger/main.ts @@ -297,8 +297,16 @@ class RubyDebugSession extends DebugSession { return subPath && !subPath.startsWith('..') && !path.isAbsolute(subPath); } - private getPathImplementation(absolutePath: string): any { - return path && path.posix.isAbsolute(absolutePath) ? path.posix : path.win32; + private getPathImplementation(pathToCheck: string): any { + if (pathToCheck) { + if (pathToCheck.indexOf(path.posix.sep) >= 0) { + return path.posix; + } else if (pathToCheck.indexOf(path.win32.sep) >= 0) { + return path.win32; + } + } + + return path; } protected convertClientPathToDebugger(localPath: string): string { From acab5e7ba6df50342d428dcf8f541b8840186307 Mon Sep 17 00:00:00 2001 From: hnioche Date: Thu, 9 May 2019 08:58:43 +0100 Subject: [PATCH 2/6] Add missing semicolon --- src/debugger/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debugger/main.ts b/src/debugger/main.ts index 707bb9b43..721d0bb87 100644 --- a/src/debugger/main.ts +++ b/src/debugger/main.ts @@ -314,7 +314,7 @@ class RubyDebugSession extends DebugSession { return localPath; } - let relativeLocalPath = path.relative(this.requestArguments.cwd, localPath) + let relativeLocalPath = path.relative(this.requestArguments.cwd, localPath); if (!this.isSubPath(relativeLocalPath)) { return localPath; From 1a62fe30124b8a7d0fb7118cb40306cc89ce713b Mon Sep 17 00:00:00 2001 From: hnioche Date: Thu, 9 May 2019 09:00:05 +0100 Subject: [PATCH 3/6] Default remote workspace to local one --- src/debugger/main.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/debugger/main.ts b/src/debugger/main.ts index 721d0bb87..9881f7d2e 100644 --- a/src/debugger/main.ts +++ b/src/debugger/main.ts @@ -320,7 +320,9 @@ class RubyDebugSession extends DebugSession { return localPath; } - let remotePathImplementation = this.getPathImplementation(this.requestArguments.remoteWorkspaceRoot); + let remoteWorkspaceRoot = this.requestArguments.remoteWorkspaceRoot || this.requestArguments.cwd; + + let remotePathImplementation = this.getPathImplementation(remoteWorkspaceRoot); let localPathImplementation = this.getPathImplementation(this.requestArguments.cwd); let relativePath = remotePathImplementation.join.apply( @@ -338,10 +340,12 @@ class RubyDebugSession extends DebugSession { return serverPath; } - let remotePathImplementation = this.getPathImplementation(this.requestArguments.remoteWorkspaceRoot); + let remoteWorkspaceRoot = this.requestArguments.remoteWorkspaceRoot || this.requestArguments.cwd; + + let remotePathImplementation = this.getPathImplementation(remoteWorkspaceRoot); let localPathImplementation = this.getPathImplementation(this.requestArguments.cwd); - let relativeRemotePath = remotePathImplementation.relative(this.requestArguments.remoteWorkspaceRoot, serverPath) + let relativeRemotePath = remotePathImplementation.relative(remoteWorkspaceRoot, serverPath); if (!this.isSubPath(relativeRemotePath)) { return serverPath; From b55c420c7ede6976703ea102b33decddb4b810c4 Mon Sep 17 00:00:00 2001 From: hnioche Date: Thu, 9 May 2019 09:19:19 +0100 Subject: [PATCH 4/6] Default remote workspace to local when generating path --- src/debugger/main.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/debugger/main.ts b/src/debugger/main.ts index 9881f7d2e..634349f57 100644 --- a/src/debugger/main.ts +++ b/src/debugger/main.ts @@ -327,9 +327,7 @@ class RubyDebugSession extends DebugSession { let relativePath = remotePathImplementation.join.apply( null, - [this.requestArguments.remoteWorkspaceRoot].concat( - relativeLocalPath.split(localPathImplementation.sep) - ) + [remoteWorkspaceRoot].concat(relativeLocalPath.split(localPathImplementation.sep)) ); return relativePath; From 3aa952c97d5becdb7c8fd7583078e2ed6a69f33c Mon Sep 17 00:00:00 2001 From: hnioche Date: Thu, 9 May 2019 09:19:52 +0100 Subject: [PATCH 5/6] Prettier changes --- src/debugger/main.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/debugger/main.ts b/src/debugger/main.ts index 634349f57..d400ac48c 100644 --- a/src/debugger/main.ts +++ b/src/debugger/main.ts @@ -320,7 +320,8 @@ class RubyDebugSession extends DebugSession { return localPath; } - let remoteWorkspaceRoot = this.requestArguments.remoteWorkspaceRoot || this.requestArguments.cwd; + let remoteWorkspaceRoot = + this.requestArguments.remoteWorkspaceRoot || this.requestArguments.cwd; let remotePathImplementation = this.getPathImplementation(remoteWorkspaceRoot); let localPathImplementation = this.getPathImplementation(this.requestArguments.cwd); @@ -338,7 +339,8 @@ class RubyDebugSession extends DebugSession { return serverPath; } - let remoteWorkspaceRoot = this.requestArguments.remoteWorkspaceRoot || this.requestArguments.cwd; + let remoteWorkspaceRoot = + this.requestArguments.remoteWorkspaceRoot || this.requestArguments.cwd; let remotePathImplementation = this.getPathImplementation(remoteWorkspaceRoot); let localPathImplementation = this.getPathImplementation(this.requestArguments.cwd); From 5a892ffc4d986e1b032e62f29025100996504494 Mon Sep 17 00:00:00 2001 From: hnioche Date: Thu, 9 May 2019 09:37:11 +0100 Subject: [PATCH 6/6] Run prettier on last changes --- src/debugger/main.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/debugger/main.ts b/src/debugger/main.ts index d400ac48c..cff68bb2d 100644 --- a/src/debugger/main.ts +++ b/src/debugger/main.ts @@ -353,9 +353,7 @@ class RubyDebugSession extends DebugSession { let relativePath = localPathImplementation.join.apply( null, - [this.requestArguments.cwd].concat( - relativeRemotePath.split(remotePathImplementation.sep) - ) + [this.requestArguments.cwd].concat(relativeRemotePath.split(remotePathImplementation.sep)) ); return relativePath;