diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2024-12-24 14:12:32 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-24 14:12:32 +0000 |
| commit | b3308bce3305193dee736d7b7e0b0ddeab161bdd (patch) | |
| tree | fb379de62d10fa58fda813e67ef0ccf5d3b1f50e | |
| parent | a63d166eeb9c95e6fd71db64ee7f64aca6eb3409 (diff) | |
| parent | b35a8467b6da2178ceade881ab1b97f6a7bc12d0 (diff) | |
| download | rust-b3308bce3305193dee736d7b7e0b0ddeab161bdd.tar.gz rust-b3308bce3305193dee736d7b7e0b0ddeab161bdd.zip | |
Merge pull request #18722 from markmurphydev/status_bar_settings
Rename `rust-analyzer.statusBar.documentSelector` to `showStatusBar`, add "always" and "never" options.
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/package.json | 73 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/config.ts | 11 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/src/ctx.ts | 13 |
3 files changed, 62 insertions, 35 deletions
diff --git a/src/tools/rust-analyzer/editors/code/package.json b/src/tools/rust-analyzer/editors/code/package.json index df97efaae73..fc3bc73b70d 100644 --- a/src/tools/rust-analyzer/editors/code/package.json +++ b/src/tools/rust-analyzer/editors/code/package.json @@ -426,40 +426,55 @@ "default": "openLogs", "markdownDescription": "Action to run when clicking the extension status bar item." }, - "rust-analyzer.statusBar.documentSelector": { - "type": [ - "array", - "null" - ], - "items": { - "type": "object", - "properties": { - "language": { - "type": [ - "string", - "null" - ] - }, - "pattern": { - "type": [ - "string", - "null" - ] - } - } - }, - "default": [ - { - "language": "rust" - }, + "rust-analyzer.statusBar.showStatusBar": { + "markdownDescription": "When to show the extension status bar.\n\n`\"always\"` Always show the status bar.\n\n`\"never\"` Never show the status bar.\n\n`{ documentSelector: <DocumentSelector>[] }` Show the status bar if the open file matches any of the given document selectors.\n\nSee [VS Code -- DocumentSelector](https://code.visualstudio.com/api/references/document-selector) for more information.", + "anyOf": [ { - "pattern": "**/Cargo.toml" + "type": "string", + "enum": [ + "always", + "never" + ] }, { - "pattern": "**/Cargo.lock" + "type": "object", + "properties": { + "documentSelector": { + "type": "array", + "items": { + "type": "object", + "properties": { + "language": { + "type": "string" + }, + "notebookType": { + "type": "string" + }, + "scheme": { + "type": "string" + }, + "pattern": { + "type": "string" + } + } + } + } + } } ], - "markdownDescription": "Determines when to show the extension status bar item based on the currently open file. Use `{ \"pattern\": \"**\" }` to always show. Use `null` to never show." + "default": { + "documentSelector": [ + { + "language": "rust" + }, + { + "pattern": "**/Cargo.toml" + }, + { + "pattern": "**/Cargo.lock" + } + ] + } } } }, diff --git a/src/tools/rust-analyzer/editors/code/src/config.ts b/src/tools/rust-analyzer/editors/code/src/config.ts index f7ef80df2ba..a97d4beab51 100644 --- a/src/tools/rust-analyzer/editors/code/src/config.ts +++ b/src/tools/rust-analyzer/editors/code/src/config.ts @@ -13,6 +13,13 @@ export type RunnableEnvCfgItem = { }; export type RunnableEnvCfg = Record<string, string> | RunnableEnvCfgItem[]; +type ShowStatusBar = + | "always" + | "never" + | { + documentSelector: vscode.DocumentSelector; + }; + export class Config { readonly extensionId = "rust-lang.rust-analyzer"; configureLang: vscode.Disposable | undefined; @@ -348,8 +355,8 @@ export class Config { return this.get<string>("statusBar.clickAction"); } - get statusBarDocumentSelector() { - return this.get<vscode.DocumentSelector>("statusBar.documentSelector"); + get statusBarShowStatusBar() { + return this.get<ShowStatusBar>("statusBar.showStatusBar"); } get initializeStopped() { diff --git a/src/tools/rust-analyzer/editors/code/src/ctx.ts b/src/tools/rust-analyzer/editors/code/src/ctx.ts index 459754b1d1c..37a54abf71f 100644 --- a/src/tools/rust-analyzer/editors/code/src/ctx.ts +++ b/src/tools/rust-analyzer/editors/code/src/ctx.ts @@ -480,14 +480,19 @@ export class Ctx implements RustAnalyzerExtensionApi { } private updateStatusBarVisibility(editor: vscode.TextEditor | undefined) { - const documentSelector = this.config.statusBarDocumentSelector; - if (documentSelector != null) { + const showStatusBar = this.config.statusBarShowStatusBar; + if (showStatusBar == null || showStatusBar === "never") { + this.statusBar.hide(); + } else if (showStatusBar === "always") { + this.statusBar.show(); + } else { + const documentSelector = showStatusBar.documentSelector; if (editor != null && vscode.languages.match(documentSelector, editor.document) > 0) { this.statusBar.show(); - return; + } else { + this.statusBar.hide(); } } - this.statusBar.hide(); } pushExtCleanup(d: Disposable) { |
