dseight / vscode-disasexpl

Disassembly Explorer for VS Code
MIT License
48 stars 11 forks source link

Update provider.ts #2

Closed mxdh closed 5 years ago

mxdh commented 5 years ago

Solve path problems.

dseight commented 5 years ago

I suppose that we should not leave path unresolved. Instead, we may do something like this:

diff --git a/src/provider.ts b/src/provider.ts
index 731a93c..0fa4a55 100644
--- a/src/provider.ts
+++ b/src/provider.ts
@@ -83,7 +83,7 @@ export function encodeAsmUri(uri: Uri): Uri {
             let associated = associations[key];
             return uri.with({
                 scheme: AsmProvider.scheme,
-                path: resolvePath(uri.path, associated)
+                path: resolvePath(uri.fsPath, associated)
             });
         }
     }

uri.fsPath will be a path without leading slash on Windows. Also, it will use system-specific path delimiters (backslashes on Windows and regular slashes on Linux/macOS).

Probably, we need to get parsedWorkspacePath in the same way:

diff --git a/src/provider.ts b/src/provider.ts
index 731a93c..05d877c 100644
--- a/src/provider.ts
+++ b/src/provider.ts
@@ -99,7 +99,7 @@ function resolvePath(path: string, associated: string): string {
     }

     let parsedFilePath = Path.parse(path);
-    let parsedWorkspacePath = Path.parse(workspace.workspaceFolders[0].uri.path);
+    let parsedWorkspacePath = Path.parse(workspace.workspaceFolders[0].uri.fsPath);

     let variables: any = {
         // the path of the folder opened in VS Code
mxdh commented 5 years ago

Sorry to have bothered you. I am a novice and I am not very familiar with javascript or typescript. Thank you.

dseight commented 5 years ago

You can just update your merge request (e.g. by force pushing to your branch) with supposed changes (if you wish) and I will merge it 😉