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 4577880d5b..52867e06f8 100644 --- a/packages/common/src/scopeSupportFacets/markdown.ts +++ b/packages/common/src/scopeSupportFacets/markdown.ts @@ -7,7 +7,11 @@ 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, "collectionItem.unenclosed": supported, }; diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index f3d49cd8b8..21c42943ca 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 e3ffa37903..669c27b49f 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 95a0c82632..aa1af86613 100644 --- a/queries/markdown.scm +++ b/queries/markdown.scm @@ -130,3 +130,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) +)