Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--editors/code/src/client.ts75
-rw-r--r--editors/code/src/ctx.ts4
2 files changed, 37 insertions, 42 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 2a1c757dfe..4ca6601a6a 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -121,59 +121,54 @@ export async function createClient(
const preview = config.previewRustcOutput;
const errorCode = config.useRustcErrorCode;
diagnosticList.forEach((diag, idx) => {
- let value =
+ const value =
typeof diag.code === "string" || typeof diag.code === "number"
? diag.code
: diag.code?.value;
if (value === "unlinked-file" && !unlinkedFiles.includes(uri)) {
- let config = vscode.workspace.getConfiguration("rust-analyzer");
+ const config = vscode.workspace.getConfiguration("rust-analyzer");
if (config.get("showUnlinkedFileNotification")) {
unlinkedFiles.push(uri);
- let folder = vscode.workspace.getWorkspaceFolder(uri)?.uri.fsPath;
+ const folder = vscode.workspace.getWorkspaceFolder(uri)?.uri.fsPath;
if (folder) {
- let parent_backslash = uri.fsPath.lastIndexOf(
+ const parentBackslash = uri.fsPath.lastIndexOf(
pathSeparator + "src"
);
- let parent = uri.fsPath.substring(0, parent_backslash);
+ const parent = uri.fsPath.substring(0, parentBackslash);
if (parent.startsWith(folder)) {
- let path = vscode.Uri.file(
+ const path = vscode.Uri.file(
parent + pathSeparator + "Cargo.toml"
);
- void vscode.workspace.fs.stat(path).then(() => {
- vscode.window
- .showInformationMessage(
- `This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at ${path}, do you want to add it to the linked Projects?`,
- "Yes",
- "No",
- "Don't show this again"
- )
- .then((choice) => {
- switch (choice) {
- case "Yes":
- break;
- case "No":
- config.update(
- "linkedProjects",
- config
- .get<any[]>("linkedProjects")
- ?.concat(
- path.fsPath.substring(
- folder!.length
- )
- ),
- false
- );
- break;
- case "Don't show this again":
- config.update(
- "showUnlinkedFileNotification",
- false,
- false
- );
- break;
- }
- });
+ void vscode.workspace.fs.stat(path).then(async () => {
+ const choice = await vscode.window.showInformationMessage(
+ `This rust file does not belong to a loaded cargo project. It looks like it might belong to the workspace at ${path}, do you want to add it to the linked Projects?`,
+ "Yes",
+ "No",
+ "Don't show this again"
+ );
+ switch (choice) {
+ case "Yes":
+ break;
+ case "No":
+ await config.update(
+ "linkedProjects",
+ config
+ .get<any[]>("linkedProjects")
+ ?.concat(
+ path.fsPath.substring(folder.length)
+ ),
+ false
+ );
+ break;
+ case "Don't show this again":
+ await config.update(
+ "showUnlinkedFileNotification",
+ false,
+ false
+ );
+ break;
+ }
});
}
}
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 5515921ed1..8a0f4ea477 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -95,7 +95,6 @@ export class Ctx {
) {
extCtx.subscriptions.push(this);
this.statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
- this.statusBar.show();
this.workspace = workspace;
this.clientSubscriptions = [];
this.commandDisposables = [];
@@ -338,6 +337,7 @@ export class Ctx {
setServerStatus(status: ServerStatusParams | { health: "stopped" }) {
let icon = "";
const statusBar = this.statusBar;
+ statusBar.show();
statusBar.tooltip = new vscode.MarkdownString("", true);
statusBar.tooltip.isTrusted = true;
switch (status.health) {
@@ -386,7 +386,7 @@ export class Ctx {
);
statusBar.tooltip.appendMarkdown("\n\n[Open logs](command:rust-analyzer.openLogs)");
statusBar.tooltip.appendMarkdown("\n\n[Restart server](command:rust-analyzer.startServer)");
- statusBar.tooltip.appendMarkdown("[Stop server](command:rust-analyzer.stopServer)");
+ statusBar.tooltip.appendMarkdown("\n\n[Stop server](command:rust-analyzer.stopServer)");
if (!status.quiescent) icon = "$(sync~spin) ";
statusBar.text = `${icon}rust-analyzer`;
}