Skip to content

Commit 2ee7ca1

Browse files
pokeyAndreasArvidssonpre-commit-ci[bot]Will-Sommers
authored
Support fully compositional modifiers (#672)
* Fixed bug in removal range for range target * A dead delimiter highlight to range target * Added token context to all marks * Added correct token context too regex * Don't unifi ranges on content only removal * Update the test * Added feature to run single recorded test * Updated tests * Fallback on token context for containing scope * Updated target inference * general refactoring of removable ranges * Updated unify removal targets * Fixed that mark bug on set selection * Fixed is reverse bug on vertical range targets * Fixed is reverse bug on vertical range targets * Set empty delimiter on end of and start of positions * Updated test * Fixed last tests * Added description to run single recorded test * At dead tests for bring before and after file * Update to removal ranges * Mark cleanup * Added interior only and exclude interior as proper modifiers * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added support for every line * Only select lines with content * Added take every paragraph * Added every file line and block tests * Added take every token * Added every too regex stages * Cleanup * Moved example of custom test transformation to docs * Update src/core/commandVersionUpgrades/upgradeV1ToV2/commandV1.types.ts Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> * Update src/core/commandVersionUpgrades/upgradeV1ToV2/upgradeV1ToV2.ts Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added OO targets * Fixed merge conflict * Reversed order of migration modifiers * Default to array * Cleaned up inference code * Added paragraph target * Better updates of new range * oo targets past all test * Added line and paragraph tests * Highlight update * Added script to show unused exports * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added line 2 unused export * Default modifiers to empty array * Don't use hat map * Modifiers default to undefined * Fixed is implicit inference * Removed get tokens function * Update src/core/commandVersionUpgrades/upgradeV1ToV2/commandV1.types.ts Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> * Update src/core/inferFullTargets.ts Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * General cleanup * Added notebook cell target * Support delimiter based edit newline (#684) * Added delimiter based edit line * Added support for arbitrary delimiters * Added tests * Renamed is above to is before * Better handling of empty lines * Cleanup * Added default delimiters for some common scope types * Run yarn * Attempt to fix raw delimiter * Fixed delimiter * Revert "Attempt to fix raw delimiter" This reverts commit 0de0798. * Revert "Fixed delimiter" This reverts commit a035390. * Use low dash unique with * Made base target abstract * Updated tests * Added return type * Fixed compilation errors * Updated position * Add empty string as default delimiter for sub tokens * Updated bugs * Cleanup * Added tests * Updated inference of implicit target * Updated spoken forms in test * Utilize getters * Refactored getters and setters for targets * Implemented get final stages * Added final stages to process targets * Cleanup * Converted command action into object with associated arguments * Switch to complex scope types * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove scope type type from base target * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated to edit new context * Added bring statement test * Change behavior of pour line * Use weak containing line stage for edit new * Updated edit new * Get targets in correct order * Updated selection for editor * Cleanup * New attempt at EditNew * Added rich targets * Updated edit new with proper line handling * Only used single edit * Added comment * Added comment * Cleanup * Added derived target * Moved weak target into base target class * Cleanup * Updated action form * Updated scope type for tests * Fix upgrade path with ordinal range * Pass leading and trailing delimiters to super constructor * Learn to spell * Updated more tests * Cleanup * Fixed bug taking matching pair in error code * Added block tests * Fixed test * Added support for custom delimiters in copy lines * Fix package json * Fix one test * Updated tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Disabled phrase snapshot on recorded test runner * Updated test and upgrade path * Fixed failing hat map tests * Added sleep option to recorded tests * Verbosity for the win * Tweak modify of week stage * Minor python cleanup * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Don't de duplicate that mark * Use utility function to set selection that deduplicates * Make document content range the entire file including white lines * Added source mark to wrap action * Added source mark to actions wrap and rewrap * Updated error messages * Updated tests * Don't focus editor on notebook cell insertion * Cleanup * Don't update selection on notebook cell insertion * Add comment * Various fixes * More renames and stuff * Fix bug with missing delimiters in weak targets * Update src/processTargets/processTargets.ts Co-authored-by: Will Sommers <will.sommers@gmail.com> * Unify implementation of copy lines and edit new actions * Rename * Started working on lazy removal * Clarify processPrimitiveTarget * Tweak * Tweak again * Imports fix * All tests pass * Updated highlights * Highlight updates on continuous range target * Moved edit decorations into graph * Added decorations to test recorder and runner * Updated to highlight recorder test * Added decorations test * Added decorations test * Added leading and trailing delimiters as separate stage and target * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Create edits in actual targets * Use object oriented targets to construct edits * Enabled bring before and after without to * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix * Support fully compositional modifiers Fixes #69 * Getting started * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Start using InsertionRemovalBehavior * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Cleanup * Tweak * More cleanup * More tweaks * Tweaks * More cleanup * Cleanup * Removed padding from float and drop * Updated that mark on pour action * Lots of stuff * Fixed removal behavior on scope type target * Hide panel on recorded test sweet startup * More stuff * More stuff * Cleanup * Some stuff clean up whatever don't care * Committed some stuff * Stuff * Updated tests * Support chuck after and chuck before * Add hack for "paste to to" * Add run single test launch config * Add comment about running a single test to contributing docs * Update cursorless-talon/src/csv_overrides.py * Update cursorless-talon/src/positional_target.py Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> * Update cursorless-talon/src/positional_target.py Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> * Use plain target in clear action * Initial modifier unification work * Unify simple modifiers * docstring * Clean up position code * At a couple comments * Creates separate file for target descriptor types * Separate notebook cell edit new from regular edit new * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixed that mark on notebook cells * Cleanup * More positional tweaks on talon side * Removes support for chuck after and chuck before * Clean up names * Use proper error for syntax scope not found * Record tests for leading trailing before and after * Add chuck before after to upgrade * Failed attempt at trying to simplify edit new * Revert "Failed attempt at trying to simplify edit new" This reverts commit 52193ae. * Cleanup vscode ignore * Fixed regression in vertical range target (#735) * Revert generic insert empty lines code * Add broken float and puff tests * Add working puff float drop tests * Switch to mocha grep syntax for running subset of tests * Make subdir for insert empty lines tests * Support updating fixture decorations * Add decorations to float drop puff tests * Cleanup test case recorder docs * Add bunch of clone tests * Move files * More cleanup * `PartialTargetDesc` => `PartialTargetDescriptor` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Re-add provenance file * Comments * Bump package version * Attempt to fix docs link Co-authored-by: Andreas Arvidsson <andreas.arvidsson87@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Will Sommers <will.sommers@gmail.com>
1 parent f27ce82 commit 2ee7ca1

File tree

393 files changed

+11365
-6835
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+11365
-6835
lines changed

.vscode/launch.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@
4141
"!**/node_modules/**"
4242
]
4343
},
44+
{
45+
"name": "Run Test Subset",
46+
"type": "extensionHost",
47+
"request": "launch",
48+
"env": {
49+
"CURSORLESS_TEST": "true",
50+
"CURSORLESS_RUN_TEST_SUBSET": "true"
51+
},
52+
"args": [
53+
"--extensions-dir=${workspaceFolder}/.vscode-sandbox/extensions",
54+
"--extensionDevelopmentPath=${workspaceFolder}",
55+
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
56+
],
57+
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
58+
"preLaunchTask": "${defaultBuildTask}",
59+
"resolveSourceMapLocations": [
60+
"${workspaceFolder}/**",
61+
"!${workspaceFolder}/.vscode-sandbox/**",
62+
"!**/node_modules/**"
63+
]
64+
},
4465
{
4566
"name": "Update fixtures",
4667
"type": "extensionHost",
@@ -62,6 +83,28 @@
6283
"!**/node_modules/**"
6384
]
6485
},
86+
{
87+
"name": "Update fixtures subset",
88+
"type": "extensionHost",
89+
"request": "launch",
90+
"env": {
91+
"CURSORLESS_TEST": "true",
92+
"CURSORLESS_TEST_UPDATE_FIXTURES": "true",
93+
"CURSORLESS_RUN_TEST_SUBSET": "true"
94+
},
95+
"args": [
96+
"--extensions-dir=${workspaceFolder}/.vscode-sandbox/extensions",
97+
"--extensionDevelopmentPath=${workspaceFolder}",
98+
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
99+
],
100+
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
101+
"preLaunchTask": "${defaultBuildTask}",
102+
"resolveSourceMapLocations": [
103+
"${workspaceFolder}/**",
104+
"!${workspaceFolder}/.vscode-sandbox/**",
105+
"!**/node_modules/**"
106+
]
107+
},
65108
{
66109
"name": "Docusaurus Start (Debug)",
67110
"type": "node",

.vscodeignore

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
.vscode/**
2-
.vscode-test/**
3-
src/**
4-
.gitignore
5-
.yarnrc
6-
vsc-extension-quickstart.md
7-
**/tsconfig.json
8-
**/.eslintrc.json
9-
**/*.map
10-
**/*.ts
11-
node_modules/**
12-
.vscode-sandbox/**
13-
out/**
14-
dist/**
1+
**
2+
!CHANGELOG.md
3+
!cursorless-snippets/**
154
!dist/extension.js
16-
website/**
5+
!images/hats/**
6+
!images/icon.png
7+
!LICENSE
8+
!NOTICE.md
9+
!package.json
10+
!README.md
11+
!schemas/**
12+
!third-party-licenses.csv
13+
!build-info.json

cursorless-talon/src/actions/actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .actions_callback import callback_action_defaults, callback_action_map
55
from .actions_custom import custom_action_defaults
66
from .actions_makeshift import makeshift_action_defaults, makeshift_action_map
7-
from .actions_simple import simple_action_defaults
7+
from .actions_simple import positional_action_defaults, simple_action_defaults
88

99
mod = Module()
1010

@@ -79,6 +79,7 @@ def vscode_command_no_wait(command_id: str, target: dict, command_options: dict
7979

8080
default_values = {
8181
"simple_action": simple_action_defaults,
82+
"positional_action": positional_action_defaults,
8283
"callback_action": callback_action_defaults,
8384
"makeshift_action": makeshift_action_defaults,
8485
"custom_action": custom_action_defaults,

cursorless-talon/src/actions/actions_makeshift.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class MakeshiftAction:
3939
"editor.action.rename",
4040
restore_selection=True,
4141
await_command=False,
42-
post_command_sleep_ms=150,
42+
post_command_sleep_ms=200,
4343
),
4444
]
4545

cursorless-talon/src/actions/actions_simple.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"give": "deselect",
2525
"highlight": "highlight",
2626
"indent": "indentLine",
27-
"paste to": "pasteFromClipboard",
2827
"post": "setSelectionAfter",
2928
"pour": "editNewLineAfter",
3029
"pre": "setSelectionBefore",
@@ -37,8 +36,18 @@
3736
"unfold": "unfoldRegion",
3837
}
3938

39+
# NOTE: Please do not change these dicts. Use the CSVs for customization.
40+
# See https://www.cursorless.org/docs/user/customization/
41+
positional_action_defaults = {
42+
"paste": "pasteFromClipboard",
43+
}
44+
4045
mod = Module()
4146
mod.list(
4247
"cursorless_simple_action",
4348
desc="Supported simple actions for cursorless navigation",
4449
)
50+
mod.list(
51+
"cursorless_positional_action",
52+
desc="Supported actions for cursorless that expect a positional target",
53+
)

cursorless-talon/src/actions/call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77

88
def run_call_action(target: dict):
9-
targets = [target, IMPLICIT_TARGET]
9+
targets = [target, IMPLICIT_TARGET.copy()]
1010
actions.user.cursorless_multiple_target_command("callAsFunction", targets)

cursorless-talon/src/actions/move_bring.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,18 @@
33
from ..primitive_target import IMPLICIT_TARGET
44

55
mod = Module()
6-
mod.list(
7-
"cursorless_source_destination_connective",
8-
desc="The connective used to separate source and destination targets",
9-
)
106

117

128
mod.list("cursorless_move_bring_action", desc="Cursorless move or bring actions")
139

1410

15-
@mod.capture(
16-
rule=(
17-
"<user.cursorless_target> [{user.cursorless_source_destination_connective} <user.cursorless_target>]"
18-
)
19-
)
11+
@mod.capture(rule="<user.cursorless_target> [<user.cursorless_positional_target>]")
2012
def cursorless_move_bring_targets(m) -> list[dict]:
2113
target_list = m.cursorless_target_list
2214

23-
if len(target_list) == 1:
24-
target_list = target_list + [IMPLICIT_TARGET]
15+
try:
16+
target_list += [m.cursorless_positional_target]
17+
except AttributeError:
18+
target_list += [IMPLICIT_TARGET.copy()]
2519

2620
return target_list

cursorless-talon/src/cheatsheet/sections/scopes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
def get_scopes():
55
return {
66
**get_lists(
7-
["scope_type", "selection_type", "subtoken_scope_type"],
7+
["scope_type", "subtoken_scope_type"],
88
{"argumentOrParameter": "Argument"},
99
),
1010
"<P>": "Paired delimiter",

cursorless-talon/src/command.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,13 @@ def construct_cursorless_command_argument(
127127
use_pre_phrase_snapshot = False
128128

129129
return {
130-
"version": 1,
130+
"version": 2,
131131
"spokenForm": get_spoken_form(),
132-
"action": action,
132+
"action": {
133+
"name": action,
134+
"args": args,
135+
},
133136
"targets": targets,
134-
"extraArgs": args,
135137
"usePrePhraseSnapshot": use_pre_phrase_snapshot,
136138
}
137139

cursorless-talon/src/compound_targets.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ def cursorless_range(m) -> str:
4444
return primitive_targets[0]
4545

4646
if len(primitive_targets) == 1:
47-
start = BASE_TARGET.copy()
47+
anchor = BASE_TARGET.copy()
4848
else:
49-
start = primitive_targets[0]
49+
anchor = primitive_targets[0]
5050

5151
range_connective = range_connective_with_type["connective"]
5252
range_type = range_connective_with_type["type"]
5353

5454
range = {
5555
"type": "range",
56-
"start": start,
57-
"end": primitive_targets[-1],
58-
"excludeStart": not is_anchor_included(range_connective),
59-
"excludeEnd": not is_active_included(range_connective),
56+
"anchor": anchor,
57+
"active": primitive_targets[-1],
58+
"excludeAnchor": not is_anchor_included(range_connective),
59+
"excludeActive": not is_active_included(range_connective),
6060
}
6161

6262
if range_type:
@@ -79,4 +79,7 @@ def is_active_included(range_connective: str):
7979
def cursorless_target(m) -> dict:
8080
if len(m.cursorless_range_list) == 1:
8181
return m.cursorless_range
82-
return {"type": "list", "elements": m.cursorless_range_list}
82+
return {
83+
"type": "list",
84+
"elements": m.cursorless_range_list,
85+
}

cursorless-talon/src/connective.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
from talon import app
1+
from talon import Module, app
22

33
from .csv_overrides import init_csv_and_watch_changes
44

5+
mod = Module()
6+
7+
mod.list(
8+
"cursorless_source_destination_connective",
9+
desc="The connective used to separate source and destination targets",
10+
)
11+
12+
513
# NOTE: Please do not change these dicts. Use the CSVs for customization.
614
# See https://www.cursorless.org/docs/user/customization/
715
range_connectives = {
@@ -11,6 +19,7 @@
1119
"until": "rangeExcludingEnd",
1220
}
1321

22+
1423
default_range_connective = "rangeInclusive"
1524

1625

cursorless-talon/src/csv_overrides.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ def update_dicts(
159159
key = obj["key"]
160160
if not is_removed(key):
161161
for k in key.split("|"):
162+
if value == "pasteFromClipboard" and k.endswith(" to"):
163+
# FIXME: This is a hack to work around the fact that the
164+
# spoken form of the `pasteFromClipboard` action used to be
165+
# "paste to", but now the spoken form is just "paste" and
166+
# the "to" is part of the positional target. Users who had
167+
# cursorless before this change would have "paste to" as
168+
# their spoken form and so would need to say "paste to to".
169+
k = k[:-3]
162170
results[obj["list"]][k.strip()] = value
163171

164172
# Assign result to talon context list

cursorless-talon/src/cursorless.talon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ app: vscode
44
<user.cursorless_action_or_vscode_command> <user.cursorless_target>:
55
user.cursorless_action_or_vscode_command(cursorless_action_or_vscode_command, cursorless_target)
66

7+
{user.cursorless_positional_action} <user.cursorless_positional_target>:
8+
user.cursorless_single_target_command(cursorless_positional_action, cursorless_positional_target)
9+
710
{user.cursorless_swap_action} <user.cursorless_swap_targets>:
811
user.cursorless_multiple_target_command(cursorless_swap_action, cursorless_swap_targets)
912

cursorless-talon/src/marks/lines_number.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dataclasses import dataclass
2+
from typing import Any, Callable
23

34
from talon import Context, Module
45

@@ -13,7 +14,7 @@ class CustomizableTerm:
1314
defaultSpokenForm: str
1415
cursorlessIdentifier: str
1516
type: str
16-
formatter: callable
17+
formatter: Callable
1718

1819

1920
# NOTE: Please do not change these dicts. Use the CSVs for customization.
@@ -33,18 +34,15 @@ class CustomizableTerm:
3334

3435

3536
@mod.capture(rule="{user.cursorless_line_direction} <number_small>")
36-
def cursorless_line_number(m) -> str:
37+
def cursorless_line_number(m) -> dict[str, Any]:
3738
direction = directions_map[m.cursorless_line_direction]
3839
line_number = m.number_small
3940
line = {
4041
"lineNumber": direction.formatter(line_number),
4142
"type": direction.type,
4243
}
4344
return {
44-
"selectionType": "line",
45-
"mark": {
46-
"type": "lineNumber",
47-
"anchor": line,
48-
"active": line,
49-
},
45+
"type": "lineNumber",
46+
"anchor": line,
47+
"active": line,
5048
}

cursorless-talon/src/marks/mark.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,17 @@
4343
@mod.capture(
4444
rule="[{user.cursorless_hat_color}] [{user.cursorless_hat_shape}] <user.any_alphanumeric_key>"
4545
)
46-
def cursorless_decorated_symbol(m) -> dict[str, dict[str, Any]]:
46+
def cursorless_decorated_symbol(m) -> dict[str, Any]:
4747
"""A decorated symbol"""
4848
hat_color = getattr(m, "cursorless_hat_color", "default")
4949
try:
5050
hat_style_name = f"{hat_color}-{m.cursorless_hat_shape}"
5151
except AttributeError:
5252
hat_style_name = hat_color
5353
return {
54-
"mark": {
55-
"type": "decoratedSymbol",
56-
"symbolColor": hat_style_name,
57-
"character": m.any_alphanumeric_key,
58-
}
54+
"type": "decoratedSymbol",
55+
"symbolColor": hat_style_name,
56+
"character": m.any_alphanumeric_key,
5957
}
6058

6159

@@ -69,10 +67,10 @@ class CustomizableTerm:
6967
# NOTE: Please do not change these dicts. Use the CSVs for customization.
7068
# See https://www.cursorless.org/docs/user/customization/
7169
special_marks = [
72-
CustomizableTerm("this", "currentSelection", {"mark": {"type": "cursor"}}),
73-
CustomizableTerm("that", "previousTarget", {"mark": {"type": "that"}}),
74-
CustomizableTerm("source", "previousSource", {"mark": {"type": "source"}}),
75-
CustomizableTerm("nothing", "nothing", {"mark": {"type": "nothing"}}),
70+
CustomizableTerm("this", "currentSelection", {"type": "cursor"}),
71+
CustomizableTerm("that", "previousTarget", {"type": "that"}),
72+
CustomizableTerm("source", "previousSource", {"type": "source"}),
73+
CustomizableTerm("nothing", "nothing", {"type": "nothing"}),
7674
# "last cursor": {"mark": {"type": "lastCursorPosition"}} # Not implemented
7775
]
7876

@@ -93,7 +91,7 @@ class CustomizableTerm:
9391
"<user.cursorless_line_number>" # row (ie absolute mod 100), up, down
9492
)
9593
)
96-
def cursorless_mark(m) -> str:
94+
def cursorless_mark(m) -> dict[str, Any]:
9795
try:
9896
return m.cursorless_decorated_symbol
9997
except AttributeError:

0 commit comments

Comments
 (0)