Skip to content

Commit

Permalink
Merge branch 'cursorless-dev:main' into cursorless-jetbrains
Browse files Browse the repository at this point in the history
  • Loading branch information
asoee authored Dec 10, 2024
2 parents 52315e2 + 6c86092 commit 9b162f9
Show file tree
Hide file tree
Showing 16 changed files with 189 additions and 39 deletions.
1 change: 1 addition & 0 deletions cursorless-talon/src/apps/vscode_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def vscode_settings_path() -> Path:
xdg_config_home / "Code/User/settings.json",
xdg_config_home / "VSCodium/User/settings.json",
xdg_config_home / "Code - OSS/User/settings.json",
xdg_config_home / "Cursor/User/settings.json",
flatpak_apps / "com.visualstudio.code/config/Code/User/settings.json",
flatpak_apps / "com.vscodium.codium/config/VSCodium/User/settings.json",
flatpak_apps
Expand Down
10 changes: 5 additions & 5 deletions cursorless-talon/src/modifiers/ordinal_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
@mod.capture(
rule="<user.ordinals_small> | [<user.ordinals_small>] {user.cursorless_last_modifier}"
)
def ordinal_or_last(m) -> int:
def cursorless_ordinal_or_last(m) -> int:
"""An ordinal or the word 'last'"""
if m[-1] == "last":
return -getattr(m, "ordinals_small", 1)
return m.ordinals_small - 1


@mod.capture(
rule="<user.ordinal_or_last> [<user.cursorless_range_connective> <user.ordinal_or_last>] <user.cursorless_scope_type>"
rule="<user.cursorless_ordinal_or_last> [<user.cursorless_range_connective> <user.cursorless_ordinal_or_last>] <user.cursorless_scope_type>"
)
def cursorless_ordinal_range(m) -> dict[str, Any]:
"""Ordinal range"""
anchor = create_ordinal_scope_modifier(
m.cursorless_scope_type, m.ordinal_or_last_list[0]
m.cursorless_scope_type, m.cursorless_ordinal_or_last_list[0]
)
if len(m.ordinal_or_last_list) > 1:
if len(m.cursorless_ordinal_or_last_list) > 1:
active = create_ordinal_scope_modifier(
m.cursorless_scope_type, m.ordinal_or_last_list[1]
m.cursorless_scope_type, m.cursorless_ordinal_or_last_list[1]
)
range_connective: RangeConnective = m.cursorless_range_connective
return {
Expand Down
5 changes: 3 additions & 2 deletions cursorless-talon/src/modifiers/simple_scope_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# This is a private setting and should not be used by non Cursorless developers
mod.setting(
"private_cursorless_use_preferred_scope",
bool,
type=bool,
default=False,
desc="Use preferred scope instead of containing scope for all scopes by default (EXPERIMENTAL)",
)

Expand All @@ -42,7 +43,7 @@ def cursorless_simple_scope_modifier(m) -> dict[str, Any]:
"ancestorIndex": 1,
}

if settings.get("user.private_cursorless_use_preferred_scope", False):
if settings.get("user.private_cursorless_use_preferred_scope"):
return {
"type": "preferredScope",
"scopeType": m.cursorless_scope_type,
Expand Down
4 changes: 2 additions & 2 deletions data/fixtures/recorded/languages/typescript/takeItem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ finalState:
const value = { a: 1, b: 2, c: 3 };
selections:
- anchor: {line: 1, character: 0}
active: {line: 1, character: 35}
- anchor: {line: 1, character: 6}
active: {line: 1, character: 34}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
let foo, bar;
---

[#1 Content] =
[#1 Domain] = 0:4-0:7
>---<
0| let foo, bar;

[#1 Removal] = 0:4-0:9
>-----<
0| let foo, bar;

[#1 Trailing delimiter] = 0:7-0:9
>--<
0| let foo, bar;

[#1 Insertion delimiter] = ", "


[#2 Content] =
[#2 Domain] = 0:9-0:12
>---<
0| let foo, bar;

[#2 Removal] = 0:7-0:12
>-----<
0| let foo, bar;

[#2 Leading delimiter] = 0:7-0:9
>--<
0| let foo, bar;

[#2 Insertion delimiter] = ", "
30 changes: 30 additions & 0 deletions data/fixtures/scopes/rust/string.singleLine.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"aaa"
r#"bbb"#
r##"ccc"##
---

[#1 Content] =
[#1 Removal] =
[#1 Domain] = 0:0-0:5
>-----<
0| "aaa"

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] =
[#2 Domain] = 1:0-1:8
>--------<
1| r#"bbb"#

[#2 Insertion delimiter] = " "


[#3 Content] =
[#3 Removal] =
[#3 Domain] = 2:0-2:10
>----------<
2| r##"ccc"##

[#3 Insertion delimiter] = " "
30 changes: 30 additions & 0 deletions data/fixtures/scopes/rust/textFragment.string.singleLine.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"aaa"
r#"bbb"#
r##"ccc"##
---

[#1 Content] =
[#1 Removal] =
[#1 Domain] = 0:1-0:4
>---<
0| "aaa"

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] =
[#2 Domain] = 1:3-1:6
>---<
1| r#"bbb"#

[#2 Insertion delimiter] = " "


[#3 Content] =
[#3 Removal] =
[#3 Domain] = 2:4-2:7
>---<
2| r##"ccc"##

[#3 Insertion delimiter] = " "
17 changes: 17 additions & 0 deletions dont_clone_monorepo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
This file exists in our monorepo so that if someone accidentally clones this monorepo
into their talon folder instead of cursorless-talon, they'll get a helpful error popup
"""

from talon import app


def on_ready():
app.notify(
"Whoops! You cloned our monorepo instead of cursorless-talon",
"Please remove cursorless and clone cursorless-talon instead:",
"https://github.com/cursorless-dev/cursorless-talon",
)


app.register("ready", on_ready)
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@types/js-yaml": "^4.0.9",
"@types/lodash-es": "4.17.12",
"@types/mocha": "^10.0.9",
"cross-spawn": "7.0.3",
"cross-spawn": "7.0.5",
"fast-check": "3.22.0",
"js-yaml": "^4.1.0",
"mocha": "^10.7.3"
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/scopeSupportFacets/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = {
"value.return": supported,
"value.return.lambda": supported,
"value.field": supported,

"collectionItem.unenclosed": supported,
};

export const javascriptJsxScopeSupport: LanguageScopeSupportFacetMap = {
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/scopeSupportFacets/rust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
export const rustScopeSupport: LanguageScopeSupportFacetMap = {
ifStatement: supported,
disqualifyDelimiter: supported,
"string.singleLine": supported,
"textFragment.string.singleLine": supported,
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,39 @@ export class ContainingScopeStage implements ModifierStage {
.run(target);
}

const containingScope = getContainingScopeTarget(
const containingScopes = getContainingScopeTarget(
target,
scopeHandler,
ancestorIndex,
);

if (containingScope == null) {
if (scopeType.type === "collectionItem") {
// For `collectionItem`, fall back to generic implementation
return this.modifierStageFactory
if (scopeType.type === "collectionItem") {
// For `collectionItem`, combine with generic implementation
try {
const legacyScopes = this.modifierStageFactory
.getLegacyScopeStage(this.modifier)
.run(target);
if (containingScopes == null) {
return legacyScopes;
}
if (containingScopes.length === 1 && legacyScopes.length === 1) {
const containingRange = containingScopes[0].contentRange;
const legacyRange = legacyScopes[0].contentRange;
if (
containingRange.contains(legacyRange) &&
!containingRange.isRangeEqual(legacyRange)
) {
return legacyScopes;
}
}
} catch (_ex) {
// Do nothing
}
}

if (containingScopes == null) {
throw new NoContainingScopeError(this.modifier.scopeType.type);
}

return containingScope;
return containingScopes;
}
}
2 changes: 1 addition & 1 deletion packages/test-harness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@types/mocha": "^10.0.9",
"@types/tail": "2.2.3",
"@vscode/test-electron": "^2.4.1",
"cross-spawn": "7.0.3",
"cross-spawn": "7.0.5",
"mocha": "^10.7.3"
},
"types": "./out/runners/extensionTestsNeovim.d.ts",
Expand Down
34 changes: 17 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b162f9

Please sign in to comment.