Skip to content

Commit 6d59219

Browse files
committed
Reduce path handling code
1 parent 1039acb commit 6d59219

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

editors/code/src/commands.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,12 @@ export function viewItemTree(ctx: Ctx): Cmd {
473473

474474
function crateGraph(ctx: Ctx, full: boolean): Cmd {
475475
return async () => {
476+
let node_modules_path = vscode.Uri.file(path.join(ctx.extensionPath, "node_modules"));
477+
476478
const panel = vscode.window.createWebviewPanel("rust-analyzer.crate-graph", "rust-analyzer crate graph", vscode.ViewColumn.Two, {
477479
enableScripts: true,
478480
retainContextWhenHidden: true,
479-
localResourceRoots: [vscode.Uri.joinPath(vscode.Uri.parse(ctx.extensionPath), "node_modules")]
481+
localResourceRoots: [node_modules_path]
480482
});
481483
const params = {
482484
full: full,
@@ -486,9 +488,9 @@ function crateGraph(ctx: Ctx, full: boolean): Cmd {
486488
console.log(dot);
487489

488490
let scripts = [
489-
{ file: vscode.Uri.file(path.join(ctx.extensionPath, 'node_modules', 'd3', 'dist', 'd3.min.js')) },
490-
{ file: vscode.Uri.file(path.join(ctx.extensionPath, 'node_modules', '@hpcc-js', 'wasm', 'dist', 'index.min.js')), worker: true },
491-
{ file: vscode.Uri.file(path.join(ctx.extensionPath, 'node_modules', 'd3-graphviz', 'build', 'd3-graphviz.min.js')) },
491+
{ file: vscode.Uri.joinPath(node_modules_path, 'd3', 'dist', 'd3.min.js') },
492+
{ file: vscode.Uri.joinPath(node_modules_path, '@hpcc-js', 'wasm', 'dist', 'index.min.js'), worker: true },
493+
{ file: vscode.Uri.joinPath(node_modules_path, 'd3-graphviz', 'build', 'd3-graphviz.min.js') },
492494
]
493495
console.log(scripts);
494496

0 commit comments

Comments
 (0)