Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cursorless-talon/src/spoken_forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"drink": "editNewLineBefore",
"drop": "insertEmptyLineBefore",
"extract": "extractVariable",
"flash": "flashTargets",
"float": "insertEmptyLineAfter",
"fold": "foldRegion",
"follow split": "followLinkAside",
Expand Down
30 changes: 30 additions & 0 deletions data/fixtures/recorded/actions/flashToken.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
languageId: plaintext
Copy link
Member

@phillco phillco Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a funny test but it does actually test more than you would think since the that mark implicitly shows you where the highlight was

command:
version: 7
spokenForm: flash token
action:
name: flashTargets
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: token}
usePrePhraseSnapshot: false
initialState:
documentContents: foo
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
marks: {}
finalState:
documentContents: foo
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
thatMark:
- type: TokenTarget
contentRange:
start: {line: 0, character: 0}
end: {line: 0, character: 3}
isReversed: false
hasExplicitRange: true
1 change: 1 addition & 0 deletions packages/common/src/types/command/ActionDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const simpleActionNames = [
"extractVariable",
"findInDocument",
"findInWorkspace",
"flashTargets",
"foldRegion",
"followLink",
"followLinkAside",
Expand Down
31 changes: 16 additions & 15 deletions packages/cursorless-engine/src/CommandHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,26 @@ function sanitizeActionInPlace(action: ActionDescriptor): void {
case "addSelectionAfter":
case "addSelectionBefore":
case "breakLine":
case "callAsFunction":
case "clearAndSetSelection":
case "copyToClipboard":
case "cutToClipboard":
case "decrement":
case "deselect":
case "editNew":
case "editNewLineAfter":
case "editNewLineBefore":
case "experimental.setInstanceReference":
case "extractVariable":
case "findInDocument":
case "findInWorkspace":
case "flashTargets":
case "foldRegion":
case "followLink":
case "followLinkAside":
case "generateSnippet":
case "getText":
case "highlight":
case "increment":
case "indentLine":
case "insertCopyAfter":
Expand All @@ -155,13 +162,21 @@ function sanitizeActionInPlace(action: ActionDescriptor): void {
case "insertEmptyLineBefore":
case "insertEmptyLinesAround":
case "joinLines":
case "moveToTarget":
case "outdentLine":
case "parsed":
case "pasteFromClipboard":
case "private.getTargets":
case "private.setKeyboardTarget":
case "private.showParseTree":
case "randomizeTargets":
case "remove":
case "rename":
case "replaceWithTarget":
case "revealDefinition":
case "revealTypeDefinition":
case "reverseTargets":
case "rewrapWithPairedDelimiter":
case "scrollToBottom":
case "scrollToCenter":
case "scrollToTop":
Expand All @@ -173,25 +188,11 @@ function sanitizeActionInPlace(action: ActionDescriptor): void {
case "showQuickFix":
case "showReferences":
case "sortTargets":
case "swapTargets":
case "toggleLineBreakpoint":
case "toggleLineComment":
case "unfoldRegion":
case "private.showParseTree":
case "private.getTargets":
case "callAsFunction":
case "editNew":
case "generateSnippet":
case "getText":
case "highlight":
case "moveToTarget":
case "pasteFromClipboard":
case "replaceWithTarget":
case "rewrapWithPairedDelimiter":
case "swapTargets":
case "wrapWithPairedDelimiter":
case "findInDocument":
case "private.setKeyboardTarget":
case "parsed":
break;

default: {
Expand Down
2 changes: 2 additions & 0 deletions packages/cursorless-engine/src/actions/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { EditNew } from "./EditNew";
import { EditNewAfter, EditNewBefore } from "./EditNewLineAction";
import ExecuteCommand from "./ExecuteCommand";
import { FindInDocument, FindInWorkspace } from "./Find";
import { FlashTargets } from "./FlashTargets";
import FollowLink from "./FollowLink";
import GenerateSnippet from "./GenerateSnippet";
import GetTargets from "./GetTargets";
Expand Down Expand Up @@ -98,6 +99,7 @@ export class Actions implements ActionRecord {
extractVariable = new ExtractVariable(this.rangeUpdater);
findInDocument = new FindInDocument(this);
findInWorkspace = new FindInWorkspace(this);
flashTargets = new FlashTargets();
foldRegion = new Fold(this.rangeUpdater);
followLink = new FollowLink({ openAside: false });
followLinkAside = new FollowLink({ openAside: true });
Expand Down
17 changes: 17 additions & 0 deletions packages/cursorless-engine/src/actions/FlashTargets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FlashStyle } from "@cursorless/common";
import { ide } from "../singletons/ide.singleton";
import type { Target } from "../typings/target.types";
import { flashTargets } from "../util/targetUtils";
import type { ActionReturnValue, SimpleAction } from "./actions.types";

export class FlashTargets implements SimpleAction {
constructor() {
this.run = this.run.bind(this);
}

async run(targets: Target[]): Promise<ActionReturnValue> {
await flashTargets(ide(), targets, FlashStyle.referenced);

return { thatTargets: targets };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export const defaultSpokenFormMapCore: DefaultSpokenFormMapDefinition = {
foldRegion: "fold",
followLink: "follow",
followLinkAside: "follow split",
flashTargets: "flash",
deselect: "give",
highlight: "highlight",
showHover: "hover",
Expand Down
Loading