Skip to content

Commit 991f18e

Browse files
committed
Merge remote-tracking branch 'origin/main' into unused-imports
2 parents 42b215c + 655df52 commit 991f18e

File tree

117 files changed

+2502
-814
lines changed

Some content is hidden

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

117 files changed

+2502
-814
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
- [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/)
44
- [ ] 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)
5+
- [ ] I have not broken the cheatsheet

cursorless-talon/src/apps/vscode_settings.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,49 +58,50 @@ def vscode_get_setting_with_fallback(
5858
"""
5959
try:
6060
return actions.user.vscode_get_setting(key, default_value), False
61-
except Exception as e:
61+
except Exception:
6262
print(fallback_message)
6363
traceback.print_exc()
6464
return fallback_value, True
6565

6666

67-
def pick_path(paths: list[Path]):
67+
def pick_path(paths: list[Path]) -> Path:
6868
existing_paths = [path for path in paths if path.exists()]
6969
return max(existing_paths, key=lambda path: path.stat().st_mtime)
7070

7171

7272
@mac_ctx.action_class("user")
7373
class MacUserActions:
7474
def vscode_settings_path() -> Path:
75+
application_support = Path.home() / "Library/Application Support"
7576
return pick_path(
7677
[
77-
Path(
78-
f"{os.environ['HOME']}/Library/Application Support/Code/User/settings.json"
79-
),
80-
Path(
81-
f"{os.environ['HOME']}/Library/Application Support/VSCodium/User/settings.json"
82-
),
78+
application_support / "Code/User/settings.json",
79+
application_support / "VSCodium/User/settings.json",
8380
]
8481
)
8582

8683

8784
@linux_ctx.action_class("user")
8885
class LinuxUserActions:
8986
def vscode_settings_path() -> Path:
87+
xdg_config_home = Path(
88+
os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")
89+
)
9090
return pick_path(
9191
[
92-
Path(f"{os.environ['HOME']}/.config/Code/User/settings.json"),
93-
Path(f"{os.environ['HOME']}/.config/VSCodium/User/settings.json"),
92+
xdg_config_home / "Code/User/settings.json",
93+
xdg_config_home / "VSCodium/User/settings.json",
9494
]
9595
)
9696

9797

9898
@windows_ctx.action_class("user")
9999
class WindowsUserActions:
100100
def vscode_settings_path() -> Path:
101+
appdata = Path(os.environ["APPDATA"])
101102
return pick_path(
102103
[
103-
Path(f"{os.environ['APPDATA']}/Code/User/settings.json"),
104-
Path(f"{os.environ['APPDATA']}/VSCodium/User/settings.json"),
104+
appdata / "Code/User/settings.json",
105+
appdata / "VSCodium/User/settings.json",
105106
]
106107
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"first_modifier",
99
"last_modifier",
1010
"previous_next_modifier",
11-
"backward_modifier",
11+
"forward_backward_modifier",
1212
]
1313

1414

cursorless-talon/src/modifiers/modifiers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .interior import interior_modifiers
66
from .ordinal_scope import first_modifiers, last_modifiers
77
from .range_type import range_types
8-
from .relative_scope import backward_modifiers, previous_next_modifiers
8+
from .relative_scope import forward_backward_modifiers, previous_next_modifiers
99
from .simple_scope_modifier import simple_scope_modifiers
1010

1111
mod = Module()
@@ -81,7 +81,7 @@ def on_ready():
8181
"first_modifier": first_modifiers,
8282
"last_modifier": last_modifiers,
8383
"previous_next_modifier": previous_next_modifiers,
84-
"backward_modifier": backward_modifiers,
84+
"forward_backward_modifier": forward_backward_modifiers,
8585
},
8686
)
8787

cursorless-talon/src/modifiers/relative_scope.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
from talon import Module
44

55
previous_next_modifiers = {"previous": "previous", "next": "next"}
6-
backward_modifiers = {"backward": "backward"}
6+
forward_backward_modifiers = {
7+
"forward": "forward",
8+
"backward": "backward",
9+
}
710

811
mod = Module()
912

1013
mod.list("cursorless_previous_next_modifier", desc="Cursorless previous/next modifiers")
11-
mod.list("cursorless_backward_modifier", desc="Cursorless backward modifiers")
14+
mod.list(
15+
"cursorless_forward_backward_modifier", desc="Cursorless forward/backward modifiers"
16+
)
1217

1318

1419
@mod.capture(rule="{user.cursorless_previous_next_modifier}")
@@ -44,26 +49,28 @@ def cursorless_relative_scope_plural(m) -> dict[str, Any]:
4449

4550

4651
@mod.capture(
47-
rule="<user.private_cursorless_number_small> <user.cursorless_scope_type_plural> [{user.cursorless_backward_modifier}]"
52+
rule="<user.private_cursorless_number_small> <user.cursorless_scope_type_plural> [{user.cursorless_forward_backward_modifier}]"
4853
)
4954
def cursorless_relative_scope_count(m) -> dict[str, Any]:
5055
"""Relative count scope. `three funks`"""
5156
return create_relative_scope_modifier(
5257
m.cursorless_scope_type_plural,
5358
0,
5459
m.private_cursorless_number_small,
55-
getattr(m, "cursorless_backward_modifier", "forward"),
60+
getattr(m, "cursorless_forward_backward_modifier", "forward"),
5661
)
5762

5863

59-
@mod.capture(rule="<user.cursorless_scope_type> {user.cursorless_backward_modifier}")
64+
@mod.capture(
65+
rule="<user.cursorless_scope_type> {user.cursorless_forward_backward_modifier}"
66+
)
6067
def cursorless_relative_scope_one_backward(m) -> dict[str, Any]:
6168
"""Take scope backward, eg `funk backward`"""
6269
return create_relative_scope_modifier(
6370
m.cursorless_scope_type,
6471
0,
6572
1,
66-
m.cursorless_backward_modifier,
73+
m.cursorless_forward_backward_modifier,
6774
)
6875

6976

docs/user/customization.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ While the hats are hidden, you will not be able to address any marks, eg `"take
7575

7676
If you'd like to map a voice command to toggle the hats, have a look at https://youtu.be/oWUJyDgz63k
7777

78+
## Updating word separators
79+
80+
The word separators are characters that defines the boundary between words in a identifier. eg `hello_world` is an identifier with two words separated by `_`. If you like to support other separators like `-` in `hello-world` that can be accomplished by changing the `cursorless.wordSeparators` setting. This setting is also language overridable.
81+
82+
```json
83+
// Sets the word separator for all languages
84+
"cursorless.wordSeparators": ["_"]
85+
86+
// Sets the word separator for css only
87+
"[css]": {
88+
"cursorless.wordSeparators": ["_", "-"]
89+
}
90+
```
91+
7892
## Cursorless public API
7993

8094
Cursorless exposes a couple talon actions and captures that you can use to define your own custom command grammar leveraging cursorless targets.

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@
207207
"description": "How much to vertically shift the hats as a percentage of font size; positive is up",
208208
"order": 1
209209
},
210+
"cursorless.wordSeparators": {
211+
"type": "array",
212+
"items": {
213+
"type": "string"
214+
},
215+
"default": [
216+
"_"
217+
],
218+
"scope": "language-overridable",
219+
"markdownDescription": "A list of characters that separate words in identifiers. For example `_` splits `hello_world` into two words.",
220+
"order": 6
221+
},
210222
"cursorless.colors.dark": {
211223
"description": "Colors to use for dark theme",
212224
"type": "object",
@@ -602,6 +614,7 @@
602614
"@types/lodash": "^4.14.168",
603615
"immer": "^9.0.15",
604616
"immutability-helper": "^3.1.1",
617+
"itertools": "^1.7.1",
605618
"lodash": "^4.17.21",
606619
"node-html-parser": "^5.3.3"
607620
}

src/core/Decorations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export default class Decorations {
5555
},
5656
),
5757

58+
// Don't use fine grained settings here until tokenizer has migrated to graph
5859
vscode.workspace.onDidChangeConfiguration(this.recomputeDecorationStyles),
5960
);
6061
}

src/core/commandRunner/CommandRunner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ export default class CommandRunner {
177177
console.error(err.stack);
178178
throw err;
179179
} finally {
180-
this.graph.testCaseRecorder.finallyHook();
180+
if (this.graph.testCaseRecorder.isActive()) {
181+
this.graph.testCaseRecorder.finallyHook();
182+
}
181183
}
182184
}
183185

src/core/languageTokenizers.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)