Skip to content

Commit 3622fb6

Browse files
committed
Fix lints
1 parent 6663693 commit 3622fb6

File tree

2 files changed

+37
-42
lines changed

2 files changed

+37
-42
lines changed

editors/code/src/client.ts

+35-40
Original file line numberDiff line numberDiff line change
@@ -121,59 +121,54 @@ export async function createClient(
121121
const preview = config.previewRustcOutput;
122122
const errorCode = config.useRustcErrorCode;
123123
diagnosticList.forEach((diag, idx) => {
124-
let value =
124+
const value =
125125
typeof diag.code === "string" || typeof diag.code === "number"
126126
? diag.code
127127
: diag.code?.value;
128128
if (value === "unlinked-file" && !unlinkedFiles.includes(uri)) {
129-
let config = vscode.workspace.getConfiguration("rust-analyzer");
129+
const config = vscode.workspace.getConfiguration("rust-analyzer");
130130
if (config.get("showUnlinkedFileNotification")) {
131131
unlinkedFiles.push(uri);
132-
let folder = vscode.workspace.getWorkspaceFolder(uri)?.uri.fsPath;
132+
const folder = vscode.workspace.getWorkspaceFolder(uri)?.uri.fsPath;
133133
if (folder) {
134-
let parent_backslash = uri.fsPath.lastIndexOf(
134+
const parentBackslash = uri.fsPath.lastIndexOf(
135135
pathSeparator + "src"
136136
);
137-
let parent = uri.fsPath.substring(0, parent_backslash);
137+
const parent = uri.fsPath.substring(0, parentBackslash);
138138

139139
if (parent.startsWith(folder)) {
140-
let path = vscode.Uri.file(
140+
const path = vscode.Uri.file(
141141
parent + pathSeparator + "Cargo.toml"
142142
);
143-
void vscode.workspace.fs.stat(path).then(() => {
144-
vscode.window
145-
.showInformationMessage(
146-
`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?`,
147-
"Yes",
148-
"No",
149-
"Don't show this again"
150-
)
151-
.then((choice) => {
152-
switch (choice) {
153-
case "Yes":
154-
break;
155-
case "No":
156-
config.update(
157-
"linkedProjects",
158-
config
159-
.get<any[]>("linkedProjects")
160-
?.concat(
161-
path.fsPath.substring(
162-
folder!.length
163-
)
164-
),
165-
false
166-
);
167-
break;
168-
case "Don't show this again":
169-
config.update(
170-
"showUnlinkedFileNotification",
171-
false,
172-
false
173-
);
174-
break;
175-
}
176-
});
143+
void vscode.workspace.fs.stat(path).then(async () => {
144+
const choice = await vscode.window.showInformationMessage(
145+
`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?`,
146+
"Yes",
147+
"No",
148+
"Don't show this again"
149+
);
150+
switch (choice) {
151+
case "Yes":
152+
break;
153+
case "No":
154+
await config.update(
155+
"linkedProjects",
156+
config
157+
.get<any[]>("linkedProjects")
158+
?.concat(
159+
path.fsPath.substring(folder.length)
160+
),
161+
false
162+
);
163+
break;
164+
case "Don't show this again":
165+
await config.update(
166+
"showUnlinkedFileNotification",
167+
false,
168+
false
169+
);
170+
break;
171+
}
177172
});
178173
}
179174
}

editors/code/src/ctx.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ export class Ctx {
9595
) {
9696
extCtx.subscriptions.push(this);
9797
this.statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
98-
this.statusBar.show();
9998
this.workspace = workspace;
10099
this.clientSubscriptions = [];
101100
this.commandDisposables = [];
@@ -338,6 +337,7 @@ export class Ctx {
338337
setServerStatus(status: ServerStatusParams | { health: "stopped" }) {
339338
let icon = "";
340339
const statusBar = this.statusBar;
340+
statusBar.show();
341341
statusBar.tooltip = new vscode.MarkdownString("", true);
342342
statusBar.tooltip.isTrusted = true;
343343
switch (status.health) {
@@ -386,7 +386,7 @@ export class Ctx {
386386
);
387387
statusBar.tooltip.appendMarkdown("\n\n[Open logs](command:rust-analyzer.openLogs)");
388388
statusBar.tooltip.appendMarkdown("\n\n[Restart server](command:rust-analyzer.startServer)");
389-
statusBar.tooltip.appendMarkdown("[Stop server](command:rust-analyzer.stopServer)");
389+
statusBar.tooltip.appendMarkdown("\n\n[Stop server](command:rust-analyzer.stopServer)");
390390
if (!status.quiescent) icon = "$(sync~spin) ";
391391
statusBar.text = `${icon}rust-analyzer`;
392392
}

0 commit comments

Comments
 (0)