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 {
2525export const cursorlessCommandIds = [
2626 "cursorless.command" ,
2727 "cursorless.internal.updateCheatsheetDefaults" ,
28+ "cursorless.private.logQuickActions" ,
2829 "cursorless.keyboard.escape" ,
2930 "cursorless.keyboard.modal.modeOff" ,
3031 "cursorless.keyboard.modal.modeOn" ,
@@ -86,6 +87,9 @@ export const cursorlessCommandDescriptions: Record<
8687 [ "cursorless.internal.updateCheatsheetDefaults" ] : new HiddenCommand (
8788 "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." ,
8889 ) ,
90+ [ "cursorless.private.logQuickActions" ] : new HiddenCommand (
91+ "Log the quick actions available at the current cursor position" ,
92+ ) ,
8993 [ "cursorless.takeSnapshot" ] : new HiddenCommand (
9094 "Take a snapshot of the current editor state" ,
9195 ) ,
Original file line number Diff line number Diff line change 4949 " onView:cursorless.scopes" ,
5050 " onCommand:cursorless.command" ,
5151 " onCommand:cursorless.internal.updateCheatsheetDefaults" ,
52+ " onCommand:cursorless.private.logQuickActions" ,
5253 " onCommand:cursorless.keyboard.escape" ,
5354 " onCommand:cursorless.keyboard.modal.modeOff" ,
5455 " onCommand:cursorless.keyboard.modal.modeOn" ,
143144 "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." ,
144145 "enablement" : " false"
145146 },
147+ {
148+ "command" : " cursorless.private.logQuickActions" ,
149+ "title" : " Cursorless: Log the quick actions available at the current cursor position" ,
150+ "enablement" : " false"
151+ },
146152 {
147153 "command" : " cursorless.takeSnapshot" ,
148154 "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 {
1010 updateDefaults ,
1111} from "@cursorless/cursorless-engine" ;
1212import * as vscode from "vscode" ;
13+ import { ScopeVisualizer } from "./ScopeVisualizerCommandApi" ;
1314import { showDocumentation , showQuickPick } from "./commands" ;
1415import { VscodeIDE } from "./ide/vscode/VscodeIDE" ;
1516import { VscodeHats } from "./ide/vscode/hats/VscodeHats" ;
1617import { KeyboardCommands } from "./keyboard/KeyboardCommands" ;
17- import { ScopeVisualizer } from "./ScopeVisualizerCommandApi " ;
18+ import { logQuickActions } from "./logQuickActions " ;
1819
1920export function registerCommands (
2021 extensionContext : vscode . ExtensionContext ,
@@ -56,6 +57,8 @@ export function registerCommands(
5657 [ "cursorless.showQuickPick" ] : showQuickPick ,
5758 [ "cursorless.showDocumentation" ] : showDocumentation ,
5859
60+ [ "cursorless.private.logQuickActions" ] : logQuickActions ,
61+
5962 // Hats
6063 [ "cursorless.toggleDecorations" ] : hats . toggle ,
6164 [ "cursorless.recomputeDecorationStyles" ] : hats . recomputeDecorationStyles ,
You can’t perform that action at this time.
0 commit comments