Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Handle cases when the outer workspace is not a rust project #419

Open
@samrg472

Description

@samrg472

I'm using Neon to create a NodeJS native module with Rust. The project layout consists of an npm project as the root and a subfolder "native" that has the rust project.

In VSCode I create a workspace with 2 folders:

  • neon-js/
  • neon-js/native

The function getOuterMostWorkspaceFolder presents an issue because the outer most folder is not a rust project.
https://github.com/rust-lang-nursery/rls-vscode/blob/096974566afe1ab34ae0f868c7dd6a127f41b059/src/extension.ts#L85-L97

I resolved this problem locally by checking if the outer most folder is a rust project. I'm not sure if this will cause problems with something else or if there's a better way, but this solution is working for me.

diff --git a/src/extension.ts b/src/extension.ts
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -90,7 +90,13 @@ function getOuterMostWorkspaceFolder(folder: WorkspaceFolder): WorkspaceFolder {
             uri = uri + '/';
         }
         if (uri.startsWith(element)) {
-            return workspace.getWorkspaceFolder(Uri.parse(element)) || folder;
+            const ws = workspace.getWorkspaceFolder(Uri.parse(element)) || folder;
+            for (const f of fs.readdirSync(ws.uri.fsPath)) {
+                if (f === 'Cargo.toml') {
+                    return ws;
+                }
+            }
+            return folder;
         }
     }
     return folder;

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-HighenhancementIndicates new feature requestsrlsIssue related to the RLS itself rather than the extension

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions