File tree Expand file tree Collapse file tree 4 files changed +55
-1
lines changed Expand file tree Collapse file tree 4 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ class VisibleCommand extends Command implements CommandDescription {
25
25
export const cursorlessCommandIds = [
26
26
"cursorless.command" ,
27
27
"cursorless.internal.updateCheatsheetDefaults" ,
28
+ "cursorless.private.logQuickActions" ,
28
29
"cursorless.keyboard.escape" ,
29
30
"cursorless.keyboard.modal.modeOff" ,
30
31
"cursorless.keyboard.modal.modeOn" ,
@@ -86,6 +87,9 @@ export const cursorlessCommandDescriptions: Record<
86
87
[ "cursorless.internal.updateCheatsheetDefaults" ] : new HiddenCommand (
87
88
"Update the default values of the cheatsheet payload used on the website and for local development. Be sure to run this on stock community and cursorless." ,
88
89
) ,
90
+ [ "cursorless.private.logQuickActions" ] : new HiddenCommand (
91
+ "Log the quick actions available at the current cursor position" ,
92
+ ) ,
89
93
[ "cursorless.takeSnapshot" ] : new HiddenCommand (
90
94
"Take a snapshot of the current editor state" ,
91
95
) ,
Original file line number Diff line number Diff line change 49
49
" onView:cursorless.scopes" ,
50
50
" onCommand:cursorless.command" ,
51
51
" onCommand:cursorless.internal.updateCheatsheetDefaults" ,
52
+ " onCommand:cursorless.private.logQuickActions" ,
52
53
" onCommand:cursorless.keyboard.escape" ,
53
54
" onCommand:cursorless.keyboard.modal.modeOff" ,
54
55
" onCommand:cursorless.keyboard.modal.modeOn" ,
143
144
"title" : " Cursorless: Update the default values of the cheatsheet payload used on the website and for local development. Be sure to run this on stock community and cursorless." ,
144
145
"enablement" : " false"
145
146
},
147
+ {
148
+ "command" : " cursorless.private.logQuickActions" ,
149
+ "title" : " Cursorless: Log the quick actions available at the current cursor position" ,
150
+ "enablement" : " false"
151
+ },
146
152
{
147
153
"command" : " cursorless.takeSnapshot" ,
148
154
"title" : " Cursorless: Take a snapshot of the current editor state" ,
Original file line number Diff line number Diff line change
1
+ import { CodeAction , commands , window } from "vscode" ;
2
+
3
+ /**
4
+ * Displays quick actions at the current cursor position in the active text
5
+ * editor.
6
+ * @param kind Optional parameter specifying the kind of quick actions to
7
+ * display. Note that kinds are hierarchical, so if you pass a more generic
8
+ * kind, the more specific sub-kinds will be logged.
9
+ * @returns A promise that resolves to an array of available code actions.
10
+ */
11
+ export async function logQuickActions ( kind ?: string ) {
12
+ const editor = window . activeTextEditor ;
13
+
14
+ if ( editor == null ) {
15
+ window . showErrorMessage ( "No active editor" ) ;
16
+ return ;
17
+ }
18
+
19
+ const availableCodeActions = (
20
+ await commands . executeCommand < CodeAction [ ] > (
21
+ "vscode.executeCodeActionProvider" ,
22
+ editor . document . uri ,
23
+ editor . selections [ 0 ] ,
24
+ kind ,
25
+ )
26
+ ) . map ( ( { title, kind, isPreferred } ) => ( {
27
+ title,
28
+ kind : kind ?. value ,
29
+ isPreferred,
30
+ } ) ) ;
31
+
32
+ availableCodeActions . forEach ( ( availableCodeAction ) => {
33
+ console . log ( `${ JSON . stringify ( availableCodeAction , null , 2 ) } ` ) ;
34
+ } ) ;
35
+
36
+ window . showInformationMessage (
37
+ "Run command 'Developer: Toggle Developer Tools' to see available code actions" ,
38
+ ) ;
39
+
40
+ return availableCodeActions ;
41
+ }
Original file line number Diff line number Diff line change @@ -10,11 +10,12 @@ import {
10
10
updateDefaults ,
11
11
} from "@cursorless/cursorless-engine" ;
12
12
import * as vscode from "vscode" ;
13
+ import { ScopeVisualizer } from "./ScopeVisualizerCommandApi" ;
13
14
import { showDocumentation , showQuickPick } from "./commands" ;
14
15
import { VscodeIDE } from "./ide/vscode/VscodeIDE" ;
15
16
import { VscodeHats } from "./ide/vscode/hats/VscodeHats" ;
16
17
import { KeyboardCommands } from "./keyboard/KeyboardCommands" ;
17
- import { ScopeVisualizer } from "./ScopeVisualizerCommandApi " ;
18
+ import { logQuickActions } from "./logQuickActions " ;
18
19
19
20
export function registerCommands (
20
21
extensionContext : vscode . ExtensionContext ,
@@ -56,6 +57,8 @@ export function registerCommands(
56
57
[ "cursorless.showQuickPick" ] : showQuickPick ,
57
58
[ "cursorless.showDocumentation" ] : showDocumentation ,
58
59
60
+ [ "cursorless.private.logQuickActions" ] : logQuickActions ,
61
+
59
62
// Hats
60
63
[ "cursorless.toggleDecorations" ] : hats . toggle ,
61
64
[ "cursorless.recomputeDecorationStyles" ] : hats . recomputeDecorationStyles ,
You can’t perform that action at this time.
0 commit comments