Skip to content

Commit

Permalink
Merge branch 'main' into javaItem
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson authored Nov 18, 2024
2 parents fc10f5a + 8cf3464 commit 17d3117
Show file tree
Hide file tree
Showing 25 changed files with 352 additions and 39 deletions.
4 changes: 2 additions & 2 deletions cursorless-talon/src/cheatsheet/sections/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_modifiers():
"variations": [
{
"spokenForm": complex_modifiers["extendThroughStartOf"],
"description": "Extend through start of line",
"description": "Extend through start of line/pair",
},
{
"spokenForm": f"{complex_modifiers['extendThroughStartOf']} <modifier>",
Expand All @@ -78,7 +78,7 @@ def get_modifiers():
"variations": [
{
"spokenForm": complex_modifiers["extendThroughEndOf"],
"description": "Extend through end of line",
"description": "Extend through end of line/pair",
},
{
"spokenForm": f"{complex_modifiers['extendThroughEndOf']} <modifier>",
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}
15 changes: 15 additions & 0 deletions data/fixtures/scopes/dart/class.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class MyClass {

}
---

[Content] =
[Removal] =
[Domain] = 0:0-2:1
>---------------
0| class MyClass {
1|
2| }
-<

[Insertion delimiter] = "\n\n"
29 changes: 29 additions & 0 deletions data/fixtures/scopes/dart/className.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class MyClass {

}
---

[Content] = 0:6-0:13
>-------<
0| class MyClass {

[Removal] = 0:6-0:14
>--------<
0| class MyClass {

[Leading delimiter] = 0:5-0:6
>-<
0| class MyClass {

[Trailing delimiter] = 0:13-0:14
>-<
0| class MyClass {

[Domain] = 0:0-2:1
>---------------
0| class MyClass {
1|
2| }
-<

[Insertion delimiter] = " "
19 changes: 19 additions & 0 deletions data/fixtures/scopes/dart/ifStatement.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
foo() {
if (true) { }
}
---

[Content] =
[Domain] = 1:2-1:15
>-------------<
1| if (true) { }

[Removal] = 1:0-1:15
>---------------<
1| if (true) { }

[Leading delimiter] = 1:0-1:2
>--<
1| if (true) { }

[Insertion delimiter] = "\n"
17 changes: 17 additions & 0 deletions data/fixtures/scopes/dart/list.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
final list = [1,2,3];
---

[Content] =
[Domain] = 0:13-0:20
>-------<
0| final list = [1,2,3];

[Removal] = 0:12-0:20
>--------<
0| final list = [1,2,3];

[Leading delimiter] = 0:12-0:13
>-<
0| final list = [1,2,3];

[Insertion delimiter] = " "
25 changes: 25 additions & 0 deletions data/fixtures/scopes/dart/map.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
final map = {
'hi': 1,
};
---

[Content] =
[Domain] = 0:14-2:3
>-
0| final map = {
1| 'hi': 1,
2| };
---<

[Removal] = 0:13-2:3
>--
0| final map = {
1| 'hi': 1,
2| };
---<

[Leading delimiter] = 0:13-0:14
>-<
0| final map = {

[Insertion delimiter] = " "
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] = " "
22 changes: 22 additions & 0 deletions data/playground/dart.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
foo() {
final hi = '';
if (hi.isNotEmpty) {

//
}


else if (true) {
//
}

final list = [1, 2, 3];

final map = {
'hi': 1,
};
}

class Something{

}
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@
"variations": [
{
"spokenForm": "tail",
"description": "Extend through end of line"
"description": "Extend through end of line/pair"
},
{
"spokenForm": "tail <modifier>",
Expand All @@ -810,7 +810,7 @@
"variations": [
{
"spokenForm": "head",
"description": "Extend through start of line"
"description": "Extend through start of line/pair"
},
{
"spokenForm": "head <modifier>",
Expand Down
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
13 changes: 13 additions & 0 deletions packages/common/src/scopeSupportFacets/dart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types";
import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;

export const dartScopeSupport: LanguageScopeSupportFacetMap = {
ifStatement: supported,
list: supported,
map: supported,
class: supported,
className: supported,
};
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { clojureScopeSupport } from "./clojure";
import { cppScopeSupport } from "./cpp";
import { csharpScopeSupport } from "./csharp";
import { cssScopeSupport } from "./css";
import { dartScopeSupport } from "./dart";
import { goScopeSupport } from "./go";
import { htmlScopeSupport } from "./html";
import { javaScopeSupport } from "./java";
Expand Down Expand Up @@ -35,6 +36,7 @@ export const languageScopeSupport: StringRecord<LanguageScopeSupportFacetMap> =
cpp: cppScopeSupport,
csharp: csharpScopeSupport,
css: cssScopeSupport,
dart: dartScopeSupport,
go: goScopeSupport,
html: htmlScopeSupport,
java: javaScopeSupport,
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: 2 additions & 0 deletions packages/cursorless-org-docs/src/docs/user/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ The modifiers `"head"` and `"tail"` can be used to expand a target through the b
- `"take head air"`: selects the mark through to start of the line
- `"take tail air"`: selects the mark through to the end of the line

When inside a single-line surrounding pair (eg parentheses, brackets, etc) the head/tail modifier will only expand to the interior of that pair instead of the whole line. You can explicitly say `"head line"` or `"tail line"` to get the line behavior.

When followed by a modifier, they will expand their input to the start or end of the given modifier range. For example:

- `"take head funk"`: select from the cursor the start of the containing function
Expand Down
5 changes: 5 additions & 0 deletions packages/cursorless-org-docs/src/docs/user/languages/dart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Language from "./Language";

# dart

<Language languageId="dart"></Language>
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
Loading

0 comments on commit 17d3117

Please sign in to comment.