@@ -2,7 +2,7 @@ import assert from 'assert';
22import { existsSync } from 'fs' ;
33import { basename } from 'path' ;
44import * as vscode from 'vscode' ;
5- import { SymbolKind } from 'vscode' ;
5+ import { SymbolKind , commands } from 'vscode' ;
66import { Disposable } from 'vscode-jsonrpc' ;
77import { ExecuteCommandRequest } from 'vscode-languageclient' ;
88import { ExtensionState } from './ExtensionState' ;
@@ -11,6 +11,9 @@ import { adaExtState, logger, mainOutputChannel } from './extension';
1111import { findAdaMain , getProjectFileRelPath , getSymbols } from './helpers' ;
1212import {
1313 SimpleTaskDef ,
14+ TASK_PROVE_FILE_PLAIN_NAME ,
15+ TASK_PROVE_LINE_PLAIN_NAME ,
16+ TASK_PROVE_REGION_PLAIN_NAME ,
1417 TASK_PROVE_SUPB_PLAIN_NAME ,
1518 TASK_TYPE_SPARK ,
1619 findBuildAndRunTask ,
@@ -140,7 +143,39 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
140143 context . subscriptions . push (
141144 vscode . commands . registerCommand ( CMD_SPARK_PROVE_SUBP , sparkProveSubprogram )
142145 ) ;
146+
147+ registerTaskWrappers ( context ) ;
148+ }
149+
150+ /**
151+ * The following commands are wrappers around VS Code tasks that allow setting
152+ * key shortcuts to the wrapped tasks. Technically it is possible to set
153+ * shortcuts directly on the `workbench.action.tasks.runTask` command with the
154+ * target task as a command argument, however in several places the UI doesn't
155+ * take into consideration the command argument, and thus it becomes impossible
156+ * to distinguish the different tasks, and worse, our shortcut becomes
157+ * displayed for the vanilla `Run Task` command.
158+ *
159+ * To avoid all that, we provide these commands as wrappers.
160+ */
161+ function registerTaskWrappers ( context : vscode . ExtensionContext ) {
162+ const sparkTaskWrappers : { [ cmdId : string ] : string } = {
163+ 'ada.spark.tasks.proveFile' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_FILE_PLAIN_NAME } ` ,
164+ 'ada.spark.tasks.proveSubprogram' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_SUPB_PLAIN_NAME } ` ,
165+ // eslint-disable-next-line max-len
166+ 'ada.spark.tasks.proveSelectedRegion' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_REGION_PLAIN_NAME } ` ,
167+ 'ada.spark.tasks.proveLine' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_LINE_PLAIN_NAME } ` ,
168+ } ;
169+ for ( const cmdId of Object . keys ( sparkTaskWrappers ) ) {
170+ const taskId = sparkTaskWrappers [ cmdId ] ;
171+ context . subscriptions . push (
172+ commands . registerCommand ( cmdId , ( ) =>
173+ commands . executeCommand ( 'workbench.action.tasks.runTask' , taskId )
174+ )
175+ ) ;
176+ }
143177}
178+
144179/**
145180 * Add a subprogram box above the subprogram enclosing the cursor's position, if any.
146181 *
0 commit comments