diff options
Diffstat (limited to 'editors')
| -rw-r--r-- | editors/code/package.json | 20 | ||||
| -rw-r--r-- | editors/code/src/commands/runnables.ts | 17 | ||||
| -rw-r--r-- | editors/code/src/config.ts | 13 |
3 files changed, 47 insertions, 3 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index 4045ab3d2..d899f60e3 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
| @@ -443,6 +443,26 @@ | |||
| 443 | "type": "object", | 443 | "type": "object", |
| 444 | "default": {}, | 444 | "default": {}, |
| 445 | "description": "Optional settings passed to the debug engine. Example:\n{ \"lldb\": { \"terminal\":\"external\"} }" | 445 | "description": "Optional settings passed to the debug engine. Example:\n{ \"lldb\": { \"terminal\":\"external\"} }" |
| 446 | }, | ||
| 447 | "rust-analyzer.lens.enable": { | ||
| 448 | "description": "Whether to show CodeLens in Rust files.", | ||
| 449 | "type": "boolean", | ||
| 450 | "default": true | ||
| 451 | }, | ||
| 452 | "rust-analyzer.lens.run": { | ||
| 453 | "markdownDescription": "Whether to show Run lens. Only applies when `#rust-analyzer.lens.enable#` is set.", | ||
| 454 | "type": "boolean", | ||
| 455 | "default": true | ||
| 456 | }, | ||
| 457 | "rust-analyzer.lens.debug": { | ||
| 458 | "markdownDescription": "Whether to show Debug lens. Only applies when `#rust-analyzer.lens.enable#` is set.", | ||
| 459 | "type": "boolean", | ||
| 460 | "default": true | ||
| 461 | }, | ||
| 462 | "rust-analyzer.lens.implementations": { | ||
| 463 | "markdownDescription": "Whether to show Implementations lens. Only applies when `#rust-analyzer.lens.enable#` is set.", | ||
| 464 | "type": "boolean", | ||
| 465 | "default": true | ||
| 446 | } | 466 | } |
| 447 | } | 467 | } |
| 448 | }, | 468 | }, |
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index b1d93fc34..0bd30fb07 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts | |||
| @@ -7,7 +7,7 @@ import { startDebugSession, getDebugConfiguration } from '../debug'; | |||
| 7 | 7 | ||
| 8 | const quickPickButtons = [{ iconPath: new vscode.ThemeIcon("save"), tooltip: "Save as a launch.json configurtation." }]; | 8 | const quickPickButtons = [{ iconPath: new vscode.ThemeIcon("save"), tooltip: "Save as a launch.json configurtation." }]; |
| 9 | 9 | ||
| 10 | async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, showButtons: boolean = true): Promise<RunnableQuickPick | undefined> { | 10 | async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, debuggeeOnly = false, showButtons: boolean = true): Promise<RunnableQuickPick | undefined> { |
| 11 | const editor = ctx.activeRustEditor; | 11 | const editor = ctx.activeRustEditor; |
| 12 | const client = ctx.client; | 12 | const client = ctx.client; |
| 13 | if (!editor || !client) return; | 13 | if (!editor || !client) return; |
| @@ -33,9 +33,20 @@ async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick, showBu | |||
| 33 | ) { | 33 | ) { |
| 34 | continue; | 34 | continue; |
| 35 | } | 35 | } |
| 36 | |||
| 37 | if (debuggeeOnly && (r.label.startsWith('doctest') || r.label.startsWith('cargo'))) { | ||
| 38 | continue; | ||
| 39 | } | ||
| 36 | items.push(new RunnableQuickPick(r)); | 40 | items.push(new RunnableQuickPick(r)); |
| 37 | } | 41 | } |
| 38 | 42 | ||
| 43 | if (items.length === 0) { | ||
| 44 | // it is the debug case, run always has at least 'cargo check ...' | ||
| 45 | // see crates\rust-analyzer\src\main_loop\handlers.rs, handle_runnables | ||
| 46 | vscode.window.showErrorMessage("There's no debug target!"); | ||
| 47 | return; | ||
| 48 | } | ||
| 49 | |||
| 39 | return await new Promise((resolve) => { | 50 | return await new Promise((resolve) => { |
| 40 | const disposables: vscode.Disposable[] = []; | 51 | const disposables: vscode.Disposable[] = []; |
| 41 | const close = (result?: RunnableQuickPick) => { | 52 | const close = (result?: RunnableQuickPick) => { |
| @@ -107,7 +118,7 @@ export function debug(ctx: Ctx): Cmd { | |||
| 107 | let prevDebuggee: RunnableQuickPick | undefined; | 118 | let prevDebuggee: RunnableQuickPick | undefined; |
| 108 | 119 | ||
| 109 | return async () => { | 120 | return async () => { |
| 110 | const item = await selectRunnable(ctx, prevDebuggee); | 121 | const item = await selectRunnable(ctx, prevDebuggee, true); |
| 111 | if (!item) return; | 122 | if (!item) return; |
| 112 | 123 | ||
| 113 | item.detail = 'restart'; | 124 | item.detail = 'restart'; |
| @@ -147,7 +158,7 @@ async function makeDebugConfig(ctx: Ctx, item: RunnableQuickPick): Promise<void> | |||
| 147 | 158 | ||
| 148 | export function newDebugConfig(ctx: Ctx): Cmd { | 159 | export function newDebugConfig(ctx: Ctx): Cmd { |
| 149 | return async () => { | 160 | return async () => { |
| 150 | const item = await selectRunnable(ctx, undefined, false); | 161 | const item = await selectRunnable(ctx, undefined, true, false); |
| 151 | if (!item) return; | 162 | if (!item) return; |
| 152 | 163 | ||
| 153 | await makeDebugConfig(ctx, item); | 164 | await makeDebugConfig(ctx, item); |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 1652827c3..ee294fbe3 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
| @@ -16,6 +16,10 @@ export class Config { | |||
| 16 | "files", | 16 | "files", |
| 17 | "highlighting", | 17 | "highlighting", |
| 18 | "updates.channel", | 18 | "updates.channel", |
| 19 | "lens.enable", | ||
| 20 | "lens.run", | ||
| 21 | "lens.debug", | ||
| 22 | "lens.implementations", | ||
| 19 | ] | 23 | ] |
| 20 | .map(opt => `${this.rootSection}.${opt}`); | 24 | .map(opt => `${this.rootSection}.${opt}`); |
| 21 | 25 | ||
| @@ -119,4 +123,13 @@ export class Config { | |||
| 119 | sourceFileMap: sourceFileMap | 123 | sourceFileMap: sourceFileMap |
| 120 | }; | 124 | }; |
| 121 | } | 125 | } |
| 126 | |||
| 127 | get lens() { | ||
| 128 | return { | ||
| 129 | enable: this.get<boolean>("lens.enable"), | ||
| 130 | run: this.get<boolean>("lens.run"), | ||
| 131 | debug: this.get<boolean>("lens.debug"), | ||
| 132 | implementations: this.get<boolean>("lens.implementations"), | ||
| 133 | }; | ||
| 134 | } | ||
| 122 | } | 135 | } |
