From 5cdfd5d36baa47689f91bf1b5ac9a3de7625d78f Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 26 Jan 2025 05:23:25 +0100 Subject: [PATCH 1/3] Merge branch 'main' into migrateSnippets --- .../languages/markdown/changeEverySection.yml | 38 +++++++++++++++ .../markdown/section.iteration.document.scope | 28 +++++++++++ .../markdown/section.iteration.parent.scope | 47 +++++++++++++++++++ .../common/src/scopeSupportFacets/markdown.ts | 4 ++ .../scopeSupportFacetInfos.ts | 12 +++++ .../scopeSupportFacets.types.ts | 2 + queries/markdown.scm | 9 ++++ 7 files changed, 140 insertions(+) create mode 100644 data/fixtures/recorded/languages/markdown/changeEverySection.yml create mode 100644 data/fixtures/scopes/markdown/section.iteration.document.scope create mode 100644 data/fixtures/scopes/markdown/section.iteration.parent.scope diff --git a/data/fixtures/recorded/languages/markdown/changeEverySection.yml b/data/fixtures/recorded/languages/markdown/changeEverySection.yml new file mode 100644 index 0000000000..99090b8676 --- /dev/null +++ b/data/fixtures/recorded/languages/markdown/changeEverySection.yml @@ -0,0 +1,38 @@ +languageId: markdown +command: + version: 7 + spokenForm: change every section + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: everyScope + scopeType: {type: section} + usePrePhraseSnapshot: false +initialState: + documentContents: |- + # h1 + Aaa + + ## h2.1 + Bbb + + ## h2.2 + Ccc + selections: + - anchor: {line: 3, character: 0} + active: {line: 3, character: 0} + marks: {} +finalState: + documentContents: |+ + # h1 + Aaa + + + + selections: + - anchor: {line: 3, character: 0} + active: {line: 3, character: 0} + - anchor: {line: 5, character: 0} + active: {line: 5, character: 0} diff --git a/data/fixtures/scopes/markdown/section.iteration.document.scope b/data/fixtures/scopes/markdown/section.iteration.document.scope new file mode 100644 index 0000000000..46c8e2751a --- /dev/null +++ b/data/fixtures/scopes/markdown/section.iteration.document.scope @@ -0,0 +1,28 @@ +# h1.1 +Aaa + +# h1.2 +Bbb +--- + +[#1 Range] = +[#1 Domain] = 0:0-4:3 + >------ +0| # h1.1 +1| Aaa +2| +3| # h1.2 +4| Bbb + ---< + + +[#2 Range] = +[#2 Domain] = 1:0-1:3 + >---< +1| Aaa + + +[#3 Range] = +[#3 Domain] = 4:0-4:3 + >---< +4| Bbb diff --git a/data/fixtures/scopes/markdown/section.iteration.parent.scope b/data/fixtures/scopes/markdown/section.iteration.parent.scope new file mode 100644 index 0000000000..d92d8434b1 --- /dev/null +++ b/data/fixtures/scopes/markdown/section.iteration.parent.scope @@ -0,0 +1,47 @@ +# h1 +Aaa + +## h2.1 +Bbb + +## h2.2 +Ccc +--- + +[#1 Range] = +[#1 Domain] = 0:0-7:3 + >---- +0| # h1 +1| Aaa +2| +3| ## h2.1 +4| Bbb +5| +6| ## h2.2 +7| Ccc + ---< + + +[#2 Range] = +[#2 Domain] = 1:0-7:3 + >--- +1| Aaa +2| +3| ## h2.1 +4| Bbb +5| +6| ## h2.2 +7| Ccc + ---< + + +[#3 Range] = +[#3 Domain] = 4:0-4:3 + >---< +4| Bbb + + +[#4 Range] = +[#4 Domain] = 7:0-7:3 + >---< +7| Ccc diff --git a/packages/common/src/scopeSupportFacets/markdown.ts b/packages/common/src/scopeSupportFacets/markdown.ts index 7831a7c036..5367391cf6 100644 --- a/packages/common/src/scopeSupportFacets/markdown.ts +++ b/packages/common/src/scopeSupportFacets/markdown.ts @@ -7,6 +7,10 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const markdownScopeSupport: LanguageScopeSupportFacetMap = { "comment.line": supported, "comment.block": supported, + section: supported, + "section.iteration.document": supported, + "section.iteration.parent": supported, + notebookCell: supported, }; diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 8c3341452b..aa73d9bc75 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -42,6 +42,18 @@ export const scopeSupportFacetInfos: Record< description: "A document section", scopeType: "section", }, + "section.iteration.document": { + description: + "Iteration scope for a document section. This is the entire document.", + scopeType: "section", + isIteration: true, + }, + "section.iteration.parent": { + description: + "Iteration scope for a document section. This is the parent section.", + scopeType: "section", + isIteration: true, + }, list: { description: "A list/array", diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 11d1d4bd5e..44eed42c02 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -13,6 +13,8 @@ export const scopeSupportFacets = [ "environment", "section", + "section.iteration.document", + "section.iteration.parent", "list", "map", diff --git a/queries/markdown.scm b/queries/markdown.scm index 1f33979a6f..df86efad9b 100644 --- a/queries/markdown.scm +++ b/queries/markdown.scm @@ -135,3 +135,12 @@ ) @sectionLevelSix @_.removal (#trim-end! @sectionLevelSix) ) + +(document) @section.iteration + +( + (section + (atx_heading) @section.iteration.start.endOf + ) @section.iteration.end.endOf + (#trim-end! @section.iteration.end.endOf) +) From 503c428fef21e3c296d9777e279cda9ee81263b1 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 28 Jan 2025 21:56:15 +0100 Subject: [PATCH 2/3] Update domain --- .../markdown/section.iteration.document.scope | 30 +++++++++----- .../markdown/section.iteration.parent.scope | 39 +++++++++++++++---- queries/markdown.scm | 3 +- 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/data/fixtures/scopes/markdown/section.iteration.document.scope b/data/fixtures/scopes/markdown/section.iteration.document.scope index 46c8e2751a..87135fafd1 100644 --- a/data/fixtures/scopes/markdown/section.iteration.document.scope +++ b/data/fixtures/scopes/markdown/section.iteration.document.scope @@ -3,26 +3,38 @@ Aaa # h1.2 Bbb + --- -[#1 Range] = -[#1 Domain] = 0:0-4:3 +[#1 Range] = 1:0-1:3 + >---< +1| Aaa + +[#1 Domain] = 0:0-1:3 >------ 0| # h1.1 1| Aaa -2| -3| # h1.2 -4| Bbb ---< [#2 Range] = -[#2 Domain] = 1:0-1:3 - >---< +[#2 Domain] = 0:0-5:0 + >------ +0| # h1.1 1| Aaa +2| +3| # h1.2 +4| Bbb +5| + < -[#3 Range] = -[#3 Domain] = 4:0-4:3 +[#3 Range] = 4:0-4:3 >---< 4| Bbb + +[#3 Domain] = 3:0-4:3 + >------ +3| # h1.2 +4| Bbb + ---< diff --git a/data/fixtures/scopes/markdown/section.iteration.parent.scope b/data/fixtures/scopes/markdown/section.iteration.parent.scope index d92d8434b1..a30eb28831 100644 --- a/data/fixtures/scopes/markdown/section.iteration.parent.scope +++ b/data/fixtures/scopes/markdown/section.iteration.parent.scope @@ -6,9 +6,20 @@ Bbb ## h2.2 Ccc + --- -[#1 Range] = +[#1 Range] = 1:0-7:3 + >--- +1| Aaa +2| +3| ## h2.1 +4| Bbb +5| +6| ## h2.2 +7| Ccc + ---< + [#1 Domain] = 0:0-7:3 >---- 0| # h1 @@ -23,8 +34,9 @@ Ccc [#2 Range] = -[#2 Domain] = 1:0-7:3 - >--- +[#2 Domain] = 0:0-8:0 + >---- +0| # h1 1| Aaa 2| 3| ## h2.1 @@ -32,16 +44,27 @@ Ccc 5| 6| ## h2.2 7| Ccc - ---< +8| + < -[#3 Range] = -[#3 Domain] = 4:0-4:3 +[#3 Range] = 4:0-4:3 >---< 4| Bbb +[#3 Domain] = 3:0-4:3 + >------- +3| ## h2.1 +4| Bbb + ---< -[#4 Range] = -[#4 Domain] = 7:0-7:3 + +[#4 Range] = 7:0-7:3 >---< 7| Ccc + +[#4 Domain] = 6:0-7:3 + >------- +6| ## h2.2 +7| Ccc + ---< diff --git a/queries/markdown.scm b/queries/markdown.scm index aa1af86613..a134b2a42d 100644 --- a/queries/markdown.scm +++ b/queries/markdown.scm @@ -136,6 +136,7 @@ ( (section (atx_heading) @section.iteration.start.endOf - ) @section.iteration.end.endOf + ) @section.iteration.end.endOf @section.iteration.domain (#trim-end! @section.iteration.end.endOf) + (#trim-end! @section.iteration.domain) ) From 52286ccfb4dd1a3d73bc0884ac7948a1f9211f9a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 28 Jan 2025 22:11:19 +0100 Subject: [PATCH 3/3] revert domain --- .../markdown/section.iteration.document.scope | 30 +++++--------- .../markdown/section.iteration.parent.scope | 39 ++++--------------- queries/markdown.scm | 3 +- 3 files changed, 18 insertions(+), 54 deletions(-) diff --git a/data/fixtures/scopes/markdown/section.iteration.document.scope b/data/fixtures/scopes/markdown/section.iteration.document.scope index 87135fafd1..46c8e2751a 100644 --- a/data/fixtures/scopes/markdown/section.iteration.document.scope +++ b/data/fixtures/scopes/markdown/section.iteration.document.scope @@ -3,38 +3,26 @@ Aaa # h1.2 Bbb - --- -[#1 Range] = 1:0-1:3 - >---< -1| Aaa - -[#1 Domain] = 0:0-1:3 +[#1 Range] = +[#1 Domain] = 0:0-4:3 >------ 0| # h1.1 1| Aaa +2| +3| # h1.2 +4| Bbb ---< [#2 Range] = -[#2 Domain] = 0:0-5:0 - >------ -0| # h1.1 +[#2 Domain] = 1:0-1:3 + >---< 1| Aaa -2| -3| # h1.2 -4| Bbb -5| - < -[#3 Range] = 4:0-4:3 +[#3 Range] = +[#3 Domain] = 4:0-4:3 >---< 4| Bbb - -[#3 Domain] = 3:0-4:3 - >------ -3| # h1.2 -4| Bbb - ---< diff --git a/data/fixtures/scopes/markdown/section.iteration.parent.scope b/data/fixtures/scopes/markdown/section.iteration.parent.scope index a30eb28831..d92d8434b1 100644 --- a/data/fixtures/scopes/markdown/section.iteration.parent.scope +++ b/data/fixtures/scopes/markdown/section.iteration.parent.scope @@ -6,20 +6,9 @@ Bbb ## h2.2 Ccc - --- -[#1 Range] = 1:0-7:3 - >--- -1| Aaa -2| -3| ## h2.1 -4| Bbb -5| -6| ## h2.2 -7| Ccc - ---< - +[#1 Range] = [#1 Domain] = 0:0-7:3 >---- 0| # h1 @@ -34,9 +23,8 @@ Ccc [#2 Range] = -[#2 Domain] = 0:0-8:0 - >---- -0| # h1 +[#2 Domain] = 1:0-7:3 + >--- 1| Aaa 2| 3| ## h2.1 @@ -44,27 +32,16 @@ Ccc 5| 6| ## h2.2 7| Ccc -8| - < + ---< -[#3 Range] = 4:0-4:3 +[#3 Range] = +[#3 Domain] = 4:0-4:3 >---< 4| Bbb -[#3 Domain] = 3:0-4:3 - >------- -3| ## h2.1 -4| Bbb - ---< - -[#4 Range] = 7:0-7:3 +[#4 Range] = +[#4 Domain] = 7:0-7:3 >---< 7| Ccc - -[#4 Domain] = 6:0-7:3 - >------- -6| ## h2.2 -7| Ccc - ---< diff --git a/queries/markdown.scm b/queries/markdown.scm index a134b2a42d..aa1af86613 100644 --- a/queries/markdown.scm +++ b/queries/markdown.scm @@ -136,7 +136,6 @@ ( (section (atx_heading) @section.iteration.start.endOf - ) @section.iteration.end.endOf @section.iteration.domain + ) @section.iteration.end.endOf (#trim-end! @section.iteration.end.endOf) - (#trim-end! @section.iteration.domain) )