Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #350 from stefansedich/master
Browse files Browse the repository at this point in the history
Only override paths when file actually exists within the cwd/remoteRoot
  • Loading branch information
wingrunr21 authored Jun 13, 2018
2 parents c21db76 + 5c8f597 commit 10bef7f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
56 changes: 32 additions & 24 deletions src/debugger/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/locate/locate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/intellisense.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 10bef7f

Please sign in to comment.