Skip to content

Commit

Permalink
Don't break jsx element text fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Jan 17, 2025
1 parent 6db1575 commit 2d37e74
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 2 deletions.
10 changes: 10 additions & 0 deletions data/fixtures/scopes/javascriptreact/textFragment.element.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div>text</div>
---

[Content] =
[Removal] =
[Domain] = 0:5-0:9
>----<
0| <div>text</div>

[Insertion delimiter] = " "
10 changes: 10 additions & 0 deletions data/fixtures/scopes/javascriptreact/textFragment.element2.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div>({value})</div>
---

[Content] =
[Removal] =
[Domain] = 0:5-0:14
>---------<
0| <div>({value})</div>

[Insertion delimiter] = " "
2 changes: 2 additions & 0 deletions packages/common/src/scopeSupportFacets/javascriptreact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;

export const javascriptreactScopeSupport: LanguageScopeSupportFacetMap = {
...javascriptScopeSupport,

"textFragment.element": supported,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { goScopeSupport } from "./go";
import { htmlScopeSupport } from "./html";
import { javaScopeSupport } from "./java";
import { javascriptScopeSupport } from "./javascript";
import { javascriptreactScopeSupport } from "./javascriptreact";
import { jsonScopeSupport } from "./json";
import { jsoncScopeSupport } from "./jsonc";
import { jsonlScopeSupport } from "./jsonl";
Expand Down Expand Up @@ -41,7 +42,7 @@ export const languageScopeSupport: StringRecord<LanguageScopeSupportFacetMap> =
html: htmlScopeSupport,
java: javaScopeSupport,
javascript: javascriptScopeSupport,
javascriptreact: javascriptScopeSupport,
javascriptreact: javascriptreactScopeSupport,
json: jsonScopeSupport,
jsonc: jsoncScopeSupport,
jsonl: jsonlScopeSupport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ export const scopeSupportFacetInfos: Record<
description: "Text fragment consisting of a multi-line string",
scopeType: "textFragment",
},
"textFragment.element": {
description: "Text fragment consisting of an xml element interior",
scopeType: "textFragment",
},

disqualifyDelimiter: {
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const scopeSupportFacets = [
"textFragment.comment.block",
"textFragment.string.singleLine",
"textFragment.string.multiLine",
"textFragment.element",

"disqualifyDelimiter",
"pairDelimiter",
Expand Down
7 changes: 6 additions & 1 deletion queries/javascript.jsx.scm
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@

;;!! <div>text</div>
;;! ^^^^
(jsx_text) @textFragment
;;!! <div>({})</div>
;;! ^^^^
(
(jsx_element) @textFragment
(#child-range! @textFragment 0 -1 true true)
)

0 comments on commit 2d37e74

Please sign in to comment.