about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/commands.ts3
-rw-r--r--editors/code/src/dependencies_provider.ts21
-rw-r--r--editors/code/src/lsp_ext.ts1
3 files changed, 19 insertions, 6 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 81d3b8da7f9..98ccd50dc04 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -276,6 +276,9 @@ export function openCargoToml(ctx: CtxInit): Cmd {
 
 export function revealDependency(ctx: CtxInit): Cmd {
     return async (editor: RustEditor) => {
+        if (!ctx.dependencies?.isInitialized()) {
+            return;
+        }
         const documentPath = editor.document.uri.fsPath;
         const dep = ctx.dependencies?.getDependency(documentPath);
         if (dep) {
diff --git a/editors/code/src/dependencies_provider.ts b/editors/code/src/dependencies_provider.ts
index 59b3b27731c..74fbacbb3cd 100644
--- a/editors/code/src/dependencies_provider.ts
+++ b/editors/code/src/dependencies_provider.ts
@@ -32,6 +32,10 @@ export class RustDependenciesProvider
         return filePath.toLowerCase() in this.dependenciesMap;
     }
 
+    isInitialized(): boolean {
+        return Object.keys(this.dependenciesMap).length !== 0;
+    }
+
     refresh(): void {
         this.dependenciesMap = {};
         this._onDidChangeTreeData.fire();
@@ -89,7 +93,12 @@ export class RustDependenciesProvider
     }
 
     private toDep(moduleName: string, version: string, path: string): Dependency {
-        return new Dependency(moduleName, version, path, vscode.TreeItemCollapsibleState.Collapsed);
+        return new Dependency(
+            moduleName,
+            version,
+            vscode.Uri.parse(path).fsPath,
+            vscode.TreeItemCollapsibleState.Collapsed
+        );
     }
 }
 
@@ -101,9 +110,9 @@ export class Dependency extends vscode.TreeItem {
         public readonly collapsibleState: vscode.TreeItemCollapsibleState
     ) {
         super(label, collapsibleState);
-        this.id = this.dependencyPath.toLowerCase();
-        this.description = this.version;
         this.resourceUri = vscode.Uri.file(dependencyPath);
+        this.id = this.resourceUri.fsPath.toLowerCase();
+        this.description = this.version;
         if (this.version) {
             this.tooltip = `${this.label}-${this.version}`;
         } else {
@@ -120,13 +129,13 @@ export class DependencyFile extends vscode.TreeItem {
         public readonly collapsibleState: vscode.TreeItemCollapsibleState
     ) {
         super(vscode.Uri.file(dependencyPath), collapsibleState);
-        this.id = this.dependencyPath.toLowerCase();
-        const isDir = fs.lstatSync(this.dependencyPath).isDirectory();
+        this.id = this.resourceUri!.fsPath.toLowerCase();
+        const isDir = fs.lstatSync(this.resourceUri!.fsPath).isDirectory();
         if (!isDir) {
             this.command = {
                 command: "vscode.open",
                 title: "Open File",
-                arguments: [vscode.Uri.file(this.dependencyPath)],
+                arguments: [this.resourceUri],
             };
         }
     }
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index b72804e510c..0d75392c92b 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -2,6 +2,7 @@
  * This file mirrors `crates/rust-analyzer/src/lsp_ext.rs` declarations.
  */
 
+import { Uri } from "vscode";
 import * as lc from "vscode-languageclient";
 
 // rust-analyzer overrides