From f963a31529c505693c34b601436cb6f6a3115f24 Mon Sep 17 00:00:00 2001 From: ERoydev Date: Thu, 6 Nov 2025 11:43:44 +0200 Subject: [PATCH] add: Add function to fetch runnable at cursor position --- editors/code/src/commands.ts | 8 ++++++++ editors/code/src/main.ts | 1 + editors/code/src/run.ts | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 16fc586d5df0..15cd51caf92f 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -14,6 +14,7 @@ import { selectRunnable, createTaskFromRunnable, createCargoArgs, + selectRunnableAtCursor, } from "./run"; import { isRustDocument, @@ -1212,6 +1213,13 @@ export function debugSingle(ctx: CtxInit): Cmd { }; } +export function fetchRunnableAtCursor(ctx: CtxInit): Cmd { + return async () => { + const editor = ctx.activeRustEditor ?? ctx.activeCargoTomlEditor; + return await selectRunnableAtCursor(ctx, editor, undefined); + }; +} + export function newDebugConfig(ctx: CtxInit): Cmd { return async () => { const item = await selectRunnable(ctx, undefined, true, false); diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 190f5866d0ea..cf1a3126ab07 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -177,6 +177,7 @@ function createCommands(): Record { copyRunCommandLine: { enabled: commands.copyRunCommandLine }, debug: { enabled: commands.debug }, newDebugConfig: { enabled: commands.newDebugConfig }, + fetchRunnableAtCursor : { enabled: commands.fetchRunnableAtCursor }, openDocs: { enabled: commands.openDocs }, openExternalDocs: { enabled: commands.openExternalDocs }, openCargoToml: { enabled: commands.openCargoToml }, diff --git a/editors/code/src/run.ts b/editors/code/src/run.ts index 87c1d529f7ee..144240213a69 100644 --- a/editors/code/src/run.ts +++ b/editors/code/src/run.ts @@ -59,7 +59,7 @@ export async function selectRunnable( ); } -async function selectRunnableAtCursor( +export async function selectRunnableAtCursor( ctx: CtxInit, editor: RustEditor, prevRunnable?: RunnableQuickPick,