Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/config.ts')
-rw-r--r--editors/code/src/config.ts28
1 files changed, 15 insertions, 13 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index d1467a4e82..2ae3291345 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -13,12 +13,7 @@ export type RunnableEnvCfgItem = {
};
export type RunnableEnvCfg = Record<string, string> | RunnableEnvCfgItem[];
-type ShowStatusBar =
- | "always"
- | "never"
- | {
- documentSelector: vscode.DocumentSelector;
- };
+type ShowStatusBar = "always" | "never" | { documentSelector: vscode.DocumentSelector };
export class Config {
readonly extensionId = "rust-lang.rust-analyzer";
@@ -145,13 +140,13 @@ export class Config {
{
// Parent doc single-line comment
// e.g. //!|
- beforeText: /^\s*\/{2}\!.*$/,
+ beforeText: /^\s*\/{2}!.*$/,
action: { indentAction, appendText: "//! " },
},
{
// Begins an auto-closed multi-line comment (standard or parent doc)
// e.g. /** | */ or /*! | */
- beforeText: /^\s*\/\*(\*|\!)(?!\/)([^\*]|\*(?!\/))*$/,
+ beforeText: /^\s*\/\*(\*|!)(?!\/)([^*]|\*(?!\/))*$/,
afterText: /^\s*\*\/$/,
action: {
indentAction: vscode.IndentAction.IndentOutdent,
@@ -161,19 +156,19 @@ export class Config {
{
// Begins a multi-line comment (standard or parent doc)
// e.g. /** ...| or /*! ...|
- beforeText: /^\s*\/\*(\*|\!)(?!\/)([^\*]|\*(?!\/))*$/,
+ beforeText: /^\s*\/\*(\*|!)(?!\/)([^*]|\*(?!\/))*$/,
action: { indentAction, appendText: " * " },
},
{
// Continues a multi-line comment
// e.g. * ...|
- beforeText: /^(\ \ )*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
+ beforeText: /^( {2})* \*( ([^*]|\*(?!\/))*)?$/,
action: { indentAction, appendText: "* " },
},
{
// Dedents after closing a multi-line comment
// e.g. */|
- beforeText: /^(\ \ )*\ \*\/\s*$/,
+ beforeText: /^( {2})* \*\/\s*$/,
action: { indentAction, removeText: 1 },
},
];
@@ -227,9 +222,11 @@ export class Config {
),
);
}
+
get checkOnSave() {
return this.get<boolean>("checkOnSave") ?? false;
}
+
async toggleCheckOnSave() {
const config = this.cfg.inspect<boolean>("checkOnSave") ?? { key: "checkOnSave" };
let overrideInLanguage;
@@ -269,8 +266,10 @@ export class Config {
}
runnablesExtraEnv(label: string): Record<string, string> | undefined {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const item = this.get<any>("runnables.extraEnv") ?? this.get<any>("runnableEnv");
if (!item) return undefined;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const fixRecord = (r: Record<string, any>) => {
for (const key in r) {
if (typeof r[key] !== "string") {
@@ -339,6 +338,7 @@ export class Config {
gotoTypeDef: this.get<boolean>("hover.actions.gotoTypeDef.enable"),
};
}
+
get previewRustcOutput() {
return this.get<boolean>("diagnostics.previewRustcOutput");
}
@@ -370,6 +370,7 @@ export class Config {
get askBeforeUpdateTest() {
return this.get<boolean>("runnables.askBeforeUpdateTest");
}
+
async setAskBeforeUpdateTest(value: boolean) {
await this.cfg.update("runnables.askBeforeUpdateTest", value, true);
}
@@ -378,11 +379,13 @@ export class Config {
export function prepareVSCodeConfig<T>(resp: T): T {
if (Is.string(resp)) {
return substituteVSCodeVariableInString(resp) as T;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
} else if (resp && Is.array<any>(resp)) {
return resp.map((val) => {
return prepareVSCodeConfig(val);
}) as T;
} else if (resp && typeof resp === "object") {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const res: { [key: string]: any } = {};
for (const key in resp) {
const val = resp[key];
@@ -489,8 +492,7 @@ function computeVscodeVar(varName: string): string | null {
// TODO: support for remote workspaces?
const fsPath: string =
folder === undefined
- ? // no workspace opened
- ""
+ ? "" // no workspace opened
: // could use currently opened document to detect the correct
// workspace. However, that would be determined by the document
// user has opened on Editor startup. Could lead to