Skip to content

Commit cf0fc20

Browse files
pokeypre-commit-ci-lite[bot]
authored andcommitted
Fix broken cheatsheet if user has custom "glyph" spoken form (#2233)
## Checklist - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [x] I have not broken the cheatsheet --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent cbff4be commit cf0fc20

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

src/cheatsheet/get_list.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ def get_raw_list(name: str) -> Mapping[str, str]:
4040
return registry.lists[cursorless_list_name][0].copy()
4141

4242

43+
def get_spoken_form_from_list(list_name: str, value: str) -> str:
44+
"""Get the spoken form of a value from a list.
45+
46+
Args:
47+
list_name (str): The name of the list.
48+
value (str): The value to look up.
49+
50+
Returns:
51+
str: The spoken form of the value.
52+
"""
53+
return next(
54+
spoken_form for spoken_form, v in get_raw_list(list_name).items() if v == value
55+
)
56+
57+
4358
def make_dict_readable(
4459
type: str, dict: Mapping[str, str], descriptions: Mapping[str, str]
4560
) -> list[ListItemDescriptor]:

src/cheatsheet/sections/compound_targets.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ..get_list import get_raw_list
1+
from ..get_list import get_raw_list, get_spoken_form_from_list
22

33
FORMATTERS = {
44
"rangeExclusive": lambda start, end: f"between {start} and {end}",
@@ -10,16 +10,10 @@
1010

1111

1212
def get_compound_targets():
13-
list_connective_term = next(
14-
spoken_form
15-
for spoken_form, value in get_raw_list("list_connective").items()
16-
if value == "listConnective"
17-
)
18-
vertical_range_term = next(
19-
spoken_form
20-
for spoken_form, value in get_raw_list("range_type").items()
21-
if value == "verticalRange"
13+
list_connective_term = get_spoken_form_from_list(
14+
"list_connective", "listConnective"
2215
)
16+
vertical_range_term = get_spoken_form_from_list("range_type", "verticalRange")
2317

2418
return [
2519
{

src/cheatsheet/sections/scopes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from ..get_list import get_lists, get_raw_list
1+
from ..get_list import get_lists, get_spoken_form_from_list
22

33

44
def get_scopes():
5-
complex_scopes = get_raw_list("glyph_scope_type")
5+
glyph_spoken_form = get_spoken_form_from_list("glyph_scope_type", "glyph")
66
return [
77
*get_lists(
88
["scope_type"],
@@ -17,7 +17,7 @@ def get_scopes():
1717
"type": "scopeType",
1818
"variations": [
1919
{
20-
"spokenForm": f"{complex_scopes['glyph']} <character>",
20+
"spokenForm": f"{glyph_spoken_form} <character>",
2121
"description": "Instance of single character <character>",
2222
},
2323
],

0 commit comments

Comments
 (0)