Skip to content

Commit 8896aa3

Browse files
AndreasArvidssonpokeypre-commit-ci[bot]
authored andcommitted
Generic scope handler interfaces (cursorless-dev#1031)
* Original scope handlers * More stuff * Use proper token stage in sub token stage * Work around for identifier matcher * Use new scope handler in relative scope stage * Use new scope handlers in ordinal scope stage * Update usage of containing indices * Rename * Refactored create target * Clean up * clean up * Add some tests that should pass * Add a bunch more tests * Attempt at different approach to scope handlers * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Initial implementation of new idea * More work on this stuff * Rename and add some todos * More stuff * Tweaks * Renames and docstrings * Restructuring * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * More jsdocs * Tweaks * Test fixes * Fix error messages * Revert `OrdinalScopeStage` * Tweak * jsdocs; fix import * Don't export legacy types * Fix import * Preparation for surrounding pairs * Naming cleanup * Unify `getLegacyScopeStage` functions * Lots of cleanup * Fix regex `lastIndex` issue * More cleanup * More cleanup * More cleanup * Add `ancestorIndex` in prepartion for cursorless-dev#124 * Add more jsdocs * More docs * More docs * docstrings * Improve hierarchical error type * Docs * More minor dog tweaks * More docs * More docs * Doc strings and a couple tests * Remove `isPreferredOver` * Support `ancestorIndex` on api surface * Improved jsdocs * Split and cleanup relative stages * Make scope handler constructor args optional * More legacy type fixes * Add `"identifier"` scope * Working new code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Docs + cheatsheet * Update docs * Add jsdoc * jsdoc * JSDocs * doc tweaks * reflow * Tweaks Co-authored-by: Pokey Rule <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent cf51fea commit 8896aa3

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/cheatsheet_html/sections/modifiers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ def get_modifiers():
121121
"spokenForm": f"{complex_modifiers['previous']} <number> <scope>s",
122122
"description": "previous <number> instances of <scope>",
123123
},
124+
{
125+
"spokenForm": f"<scope> {complex_modifiers['backward']}",
126+
"description": "single instance of <scope> including target, going backwards",
127+
},
124128
{
125129
"spokenForm": f"<number> <scope>s {complex_modifiers['backward']}",
126130
"description": "<number> instances of <scope> including target, going backwards",

src/modifiers/relative_scope.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,23 @@ def cursorless_relative_scope_count(m) -> dict[str, Any]:
5656
)
5757

5858

59+
@mod.capture(rule="<user.cursorless_scope_type> {user.cursorless_backward_modifier}")
60+
def cursorless_relative_scope_one_backward(m) -> dict[str, Any]:
61+
"""Take scope backward, eg `funk backward`"""
62+
return create_relative_scope_modifier(
63+
m.cursorless_scope_type,
64+
0,
65+
1,
66+
m.cursorless_backward_modifier,
67+
)
68+
69+
5970
@mod.capture(
6071
rule=(
6172
"<user.cursorless_relative_scope_singular> | "
6273
"<user.cursorless_relative_scope_plural> | "
63-
"<user.cursorless_relative_scope_count>"
74+
"<user.cursorless_relative_scope_count> | "
75+
"<user.cursorless_relative_scope_one_backward>"
6476
)
6577
)
6678
def cursorless_relative_scope(m) -> dict[str, Any]:

src/modifiers/scopes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
# Text-based scope types
5959
"char": "character",
6060
"word": "word",
61+
"identifier": "identifier",
6162
"block": "paragraph",
6263
"cell": "notebookCell",
6364
"file": "document",

0 commit comments

Comments
 (0)