diff --git a/src/debugger/main.ts b/src/debugger/main.ts index 26a663f7c..03e82a6d9 100644 --- a/src/debugger/main.ts +++ b/src/debugger/main.ts @@ -293,36 +293,44 @@ class RubyDebugSession extends DebugSession { return localPath.replace(/\\/g, '/'); } - protected convertClientPathToDebugger(localPath: string): string { - if (this.debugMode == Mode.launch) { - return localPath; - } + protected convertClientPathToDebugger(localPath: string): string { + if (this.debugMode == Mode.launch) { + return localPath; + } - var relativePath = path.join( - this.requestArguments.remoteWorkspaceRoot, localPath.substring(this.requestArguments.cwd.length) - ); + if (!localPath.startsWith(this.requestArguments.cwd)) { + return localPath; + } - var sepIndex = this.requestArguments.remoteWorkspaceRoot.lastIndexOf('/'); + var relativePath = path.join( + this.requestArguments.remoteWorkspaceRoot, localPath.substring(this.requestArguments.cwd.length) + ); - if (sepIndex !== -1) { - // *inx or darwin - relativePath = relativePath.replace(/\\/g, '/'); - } + var sepIndex = this.requestArguments.remoteWorkspaceRoot.lastIndexOf('/'); - return relativePath; - } + if (sepIndex !== -1) { + // *inx or darwin + relativePath = relativePath.replace(/\\/g, '/'); + } - protected convertDebuggerPathToClient(serverPath: string):string{ - if (this.debugMode == Mode.launch) { - return serverPath; - } + return relativePath; + } - // Path.join will convert the path using local OS preferred separator - var relativePath = path.join( - this.requestArguments.cwd, serverPath.substring(this.requestArguments.remoteWorkspaceRoot.length) - ); - return relativePath; - } + protected convertDebuggerPathToClient(serverPath: string):string{ + if (this.debugMode == Mode.launch) { + return serverPath; + } + + if (!serverPath.startsWith(this.requestArguments.remoteWorkspaceRoot)) { + return serverPath; + } + + // Path.join will convert the path using local OS preferred separator + var relativePath = path.join( + this.requestArguments.cwd, serverPath.substring(this.requestArguments.remoteWorkspaceRoot.length) + ); + return relativePath; + } protected switchFrame(frameId) { if (frameId === this._frameId) return; diff --git a/src/locate/locate.js b/src/locate/locate.js index ce75c2c1a..f1e72388f 100644 --- a/src/locate/locate.js +++ b/src/locate/locate.js @@ -60,7 +60,7 @@ function filter(symbols, query, matcher) { .uniq() .value(); } -module.exports = class Locate { +export class Locate { constructor(root, settings) { this.settings = settings; this.root = root; diff --git a/src/providers/intellisense.ts b/src/providers/intellisense.ts index 0e7b3e984..ad5cd875b 100644 --- a/src/providers/intellisense.ts +++ b/src/providers/intellisense.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; import { ExtensionContext, SymbolKind, SymbolInformation } from 'vscode'; -import * as Locate from '../locate/locate'; +import { Locate } from '../locate/locate'; export function registerIntellisenseProvider(ctx: ExtensionContext) { // for locate: if it's a project, use the root, othewise, don't bother