Skip to content

Commit 6c1e0ce

Browse files
Don't break jsx element text fragments (#2732)
Fixes #2730 ## Checklist - [x] 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) - [/] I have not broken the cheatsheet
1 parent 6db1575 commit 6c1e0ce

File tree

7 files changed

+35
-2
lines changed

7 files changed

+35
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div>text</div>
2+
---
3+
4+
[Content] =
5+
[Removal] =
6+
[Domain] = 0:5-0:9
7+
>----<
8+
0| <div>text</div>
9+
10+
[Insertion delimiter] = " "
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div>({value})</div>
2+
---
3+
4+
[Content] =
5+
[Removal] =
6+
[Domain] = 0:5-0:14
7+
>---------<
8+
0| <div>({value})</div>
9+
10+
[Insertion delimiter] = " "

packages/common/src/scopeSupportFacets/javascriptreact.ts

+2
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
77

88
export const javascriptreactScopeSupport: LanguageScopeSupportFacetMap = {
99
...javascriptScopeSupport,
10+
11+
"textFragment.element": supported,
1012
};

packages/common/src/scopeSupportFacets/languageScopeSupport.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { goScopeSupport } from "./go";
99
import { htmlScopeSupport } from "./html";
1010
import { javaScopeSupport } from "./java";
1111
import { javascriptScopeSupport } from "./javascript";
12+
import { javascriptreactScopeSupport } from "./javascriptreact";
1213
import { jsonScopeSupport } from "./json";
1314
import { jsoncScopeSupport } from "./jsonc";
1415
import { jsonlScopeSupport } from "./jsonl";
@@ -41,7 +42,7 @@ export const languageScopeSupport: StringRecord<LanguageScopeSupportFacetMap> =
4142
html: htmlScopeSupport,
4243
java: javaScopeSupport,
4344
javascript: javascriptScopeSupport,
44-
javascriptreact: javascriptScopeSupport,
45+
javascriptreact: javascriptreactScopeSupport,
4546
json: jsonScopeSupport,
4647
jsonc: jsoncScopeSupport,
4748
jsonl: jsonlScopeSupport,

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

+4
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ export const scopeSupportFacetInfos: Record<
292292
description: "Text fragment consisting of a multi-line string",
293293
scopeType: "textFragment",
294294
},
295+
"textFragment.element": {
296+
description: "Text fragment consisting of an xml element interior",
297+
scopeType: "textFragment",
298+
},
295299

296300
disqualifyDelimiter: {
297301
description:

packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export const scopeSupportFacets = [
7878
"textFragment.comment.block",
7979
"textFragment.string.singleLine",
8080
"textFragment.string.multiLine",
81+
"textFragment.element",
8182

8283
"disqualifyDelimiter",
8384
"pairDelimiter",

queries/javascript.jsx.scm

+6-1
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,9 @@
9090

9191
;;!! <div>text</div>
9292
;;! ^^^^
93-
(jsx_text) @textFragment
93+
;;!! <div>({})</div>
94+
;;! ^^^^
95+
(
96+
(jsx_element) @textFragment
97+
(#child-range! @textFragment 0 -1 true true)
98+
)

0 commit comments

Comments
 (0)