about summary refs log tree commit diff
path: root/editors/code
diff options
context:
space:
mode:
authorhecatia-elegua <108802164+hecatia-elegua@users.noreply.github.com>2023-04-11 21:14:52 +0200
committerGitHub <noreply@github.com>2023-04-11 21:14:52 +0200
commit398af0259f7614ff8a0d603edd5d94ce9aecd5f2 (patch)
tree207fc25b5c6d73d5c7833fab11d24d2fa5a837d7 /editors/code
parent33ee157f3b05865984957953df21f4711f8e5cd6 (diff)
parent7501d3b721560637e27f904d9fce79182c41bef7 (diff)
downloadrust-398af0259f7614ff8a0d603edd5d94ce9aecd5f2.tar.gz
rust-398af0259f7614ff8a0d603edd5d94ce9aecd5f2.zip
Merge branch 'master' into alias-based-completion2
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package.json17
-rw-r--r--editors/code/src/client.ts6
-rw-r--r--editors/code/src/commands.ts13
-rw-r--r--editors/code/src/ctx.ts14
4 files changed, 37 insertions, 13 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 81fa97269a9..087fd1296b3 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -1028,6 +1028,23 @@
                         "Only show type hints for return types of closures with blocks."
                     ]
                 },
+                "rust-analyzer.inlayHints.closureStyle": {
+                    "markdownDescription": "Closure notation in type and chaining inaly hints.",
+                    "default": "impl_fn",
+                    "type": "string",
+                    "enum": [
+                        "impl_fn",
+                        "rust_analyzer",
+                        "with_id",
+                        "hide"
+                    ],
+                    "enumDescriptions": [
+                        "`impl_fn`: `impl FnMut(i32, u64) -> i8`",
+                        "`rust_analyzer`: `|i32, u64| -> i8`",
+                        "`with_id`: `{closure#14352}`, where that id is the unique number of the closure in r-a internals",
+                        "`hide`: Shows `...` for every closure type"
+                    ]
+                },
                 "rust-analyzer.inlayHints.discriminantHints.enable": {
                     "markdownDescription": "Whether to show enum variant discriminant hints.",
                     "default": "never",
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index e76710cb247..b27d9f54943 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -125,7 +125,11 @@ export async function createClient(
                         typeof diag.code === "string" || typeof diag.code === "number"
                             ? diag.code
                             : diag.code?.value;
-                    if (value === "unlinked-file" && !unlinkedFiles.includes(uri)) {
+                    if (
+                        value === "unlinked-file" &&
+                        !unlinkedFiles.includes(uri) &&
+                        diag.message !== "file not included in module tree"
+                    ) {
                         const config = vscode.workspace.getConfiguration("rust-analyzer");
                         if (config.get("showUnlinkedFileNotification")) {
                             unlinkedFiles.push(uri);
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 7a8490e4767..4438d475ad9 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -761,12 +761,13 @@ export function addProject(ctx: CtxInit): Cmd {
         }
 
         const workspaces: JsonProject[] = await Promise.all(
-            vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
-                const rustDocuments = vscode.workspace.textDocuments.filter(isRustDocument);
-                return discoverWorkspace(rustDocuments, discoverProjectCommand, {
-                    cwd: folder.uri.fsPath,
-                });
-            })
+            vscode.workspace.textDocuments
+                .filter(isRustDocument)
+                .map(async (file): Promise<JsonProject> => {
+                    return discoverWorkspace([file], discoverProjectCommand, {
+                        cwd: path.dirname(file.uri.fsPath),
+                    });
+                })
         );
 
         ctx.addToDiscoveredWorkspaces(workspaces);
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index dd74b31cc71..0ffa42c2a5a 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -1,6 +1,7 @@
 import * as vscode from "vscode";
 import * as lc from "vscode-languageclient/node";
 import * as ra from "./lsp_ext";
+import * as path from "path";
 
 import { Config, prepareVSCodeConfig } from "./config";
 import { createClient } from "./client";
@@ -192,12 +193,13 @@ export class Ctx {
             const discoverProjectCommand = this.config.discoverProjectCommand;
             if (discoverProjectCommand) {
                 const workspaces: JsonProject[] = await Promise.all(
-                    vscode.workspace.workspaceFolders!.map(async (folder): Promise<JsonProject> => {
-                        const rustDocuments = vscode.workspace.textDocuments.filter(isRustDocument);
-                        return discoverWorkspace(rustDocuments, discoverProjectCommand, {
-                            cwd: folder.uri.fsPath,
-                        });
-                    })
+                    vscode.workspace.textDocuments
+                        .filter(isRustDocument)
+                        .map(async (file): Promise<JsonProject> => {
+                            return discoverWorkspace([file], discoverProjectCommand, {
+                                cwd: path.dirname(file.uri.fsPath),
+                            });
+                        })
                 );
 
                 this.addToDiscoveredWorkspaces(workspaces);