From 2d37e747f67c9e7fced8cfe9c3d3a8efee7216c9 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 17 Jan 2025 19:22:42 +0100 Subject: [PATCH] Don't break jsx element text fragments --- .../scopes/javascriptreact/textFragment.element.scope | 10 ++++++++++ .../scopes/javascriptreact/textFragment.element2.scope | 10 ++++++++++ .../common/src/scopeSupportFacets/javascriptreact.ts | 2 ++ .../src/scopeSupportFacets/languageScopeSupport.ts | 3 ++- .../src/scopeSupportFacets/scopeSupportFacetInfos.ts | 4 ++++ .../src/scopeSupportFacets/scopeSupportFacets.types.ts | 1 + queries/javascript.jsx.scm | 7 ++++++- 7 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 data/fixtures/scopes/javascriptreact/textFragment.element.scope create mode 100644 data/fixtures/scopes/javascriptreact/textFragment.element2.scope diff --git a/data/fixtures/scopes/javascriptreact/textFragment.element.scope b/data/fixtures/scopes/javascriptreact/textFragment.element.scope new file mode 100644 index 0000000000..723c8bfea7 --- /dev/null +++ b/data/fixtures/scopes/javascriptreact/textFragment.element.scope @@ -0,0 +1,10 @@ +
text
+--- + +[Content] = +[Removal] = +[Domain] = 0:5-0:9 + >----< +0|
text
+ +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascriptreact/textFragment.element2.scope b/data/fixtures/scopes/javascriptreact/textFragment.element2.scope new file mode 100644 index 0000000000..3cb0e8a63c --- /dev/null +++ b/data/fixtures/scopes/javascriptreact/textFragment.element2.scope @@ -0,0 +1,10 @@ +
({value})
+--- + +[Content] = +[Removal] = +[Domain] = 0:5-0:14 + >---------< +0|
({value})
+ +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/javascriptreact.ts b/packages/common/src/scopeSupportFacets/javascriptreact.ts index f11e9db3d5..2d38ba0c5f 100644 --- a/packages/common/src/scopeSupportFacets/javascriptreact.ts +++ b/packages/common/src/scopeSupportFacets/javascriptreact.ts @@ -7,4 +7,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const javascriptreactScopeSupport: LanguageScopeSupportFacetMap = { ...javascriptScopeSupport, + + "textFragment.element": supported, }; diff --git a/packages/common/src/scopeSupportFacets/languageScopeSupport.ts b/packages/common/src/scopeSupportFacets/languageScopeSupport.ts index 2c05c76c6b..8a2c0124a6 100644 --- a/packages/common/src/scopeSupportFacets/languageScopeSupport.ts +++ b/packages/common/src/scopeSupportFacets/languageScopeSupport.ts @@ -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"; @@ -41,7 +42,7 @@ export const languageScopeSupport: StringRecord = html: htmlScopeSupport, java: javaScopeSupport, javascript: javascriptScopeSupport, - javascriptreact: javascriptScopeSupport, + javascriptreact: javascriptreactScopeSupport, json: jsonScopeSupport, jsonc: jsoncScopeSupport, jsonl: jsonlScopeSupport, diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 8102ca4d8e..12b1b412e1 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -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: diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 7983aa9384..671d1efefe 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -78,6 +78,7 @@ export const scopeSupportFacets = [ "textFragment.comment.block", "textFragment.string.singleLine", "textFragment.string.multiLine", + "textFragment.element", "disqualifyDelimiter", "pairDelimiter", diff --git a/queries/javascript.jsx.scm b/queries/javascript.jsx.scm index adcf86a59e..6cad71af0d 100644 --- a/queries/javascript.jsx.scm +++ b/queries/javascript.jsx.scm @@ -90,4 +90,9 @@ ;;!!
text
;;! ^^^^ -(jsx_text) @textFragment +;;!!
({})
+;;! ^^^^ +( + (jsx_element) @textFragment + (#child-range! @textFragment 0 -1 true true) +)