From 9c2ad303d59f22792afe262c3cdf41925cd8f572 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 26 Jan 2025 18:16:31 +0100 Subject: [PATCH] Update ranges for markdown item --- .../languages/markdown/changeLeadingItem.yml | 7 +- .../languages/markdown/chuckItem4.yml | 5 +- .../languages/markdown/roundWrapItemAir.yml | 4 +- .../markdown/collectionItem.unenclosed.scope | 69 +++++++++++++++++++ .../common/src/scopeSupportFacets/markdown.ts | 1 + queries/markdown.scm | 21 +++--- 6 files changed, 87 insertions(+), 20 deletions(-) create mode 100644 data/fixtures/scopes/markdown/collectionItem.unenclosed.scope diff --git a/data/fixtures/recorded/languages/markdown/changeLeadingItem.yml b/data/fixtures/recorded/languages/markdown/changeLeadingItem.yml index fd0d38aece..e057271d27 100644 --- a/data/fixtures/recorded/languages/markdown/changeLeadingItem.yml +++ b/data/fixtures/recorded/languages/markdown/changeLeadingItem.yml @@ -24,8 +24,9 @@ initialState: finalState: documentContents: |- - values - - 0- 1 + - 0 + - 1 - 2 selections: - - anchor: {line: 1, character: 7} - active: {line: 1, character: 7} + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} diff --git a/data/fixtures/recorded/languages/markdown/chuckItem4.yml b/data/fixtures/recorded/languages/markdown/chuckItem4.yml index 9178465ace..cf045e1eed 100644 --- a/data/fixtures/recorded/languages/markdown/chuckItem4.yml +++ b/data/fixtures/recorded/languages/markdown/chuckItem4.yml @@ -23,6 +23,7 @@ finalState: documentContents: |- - values - 0 + selections: - - anchor: {line: 1, character: 7} - active: {line: 1, character: 7} + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} diff --git a/data/fixtures/recorded/languages/markdown/roundWrapItemAir.yml b/data/fixtures/recorded/languages/markdown/roundWrapItemAir.yml index 186d91b04f..cda1c2f4ab 100644 --- a/data/fixtures/recorded/languages/markdown/roundWrapItemAir.yml +++ b/data/fixtures/recorded/languages/markdown/roundWrapItemAir.yml @@ -26,8 +26,8 @@ initialState: end: {line: 0, character: 5} finalState: documentContents: | - - (aaa) - - bbb + - (aaa + - bbb) selections: - anchor: {line: 2, character: 0} active: {line: 2, character: 0} diff --git a/data/fixtures/scopes/markdown/collectionItem.unenclosed.scope b/data/fixtures/scopes/markdown/collectionItem.unenclosed.scope new file mode 100644 index 0000000000..4fe3448bd7 --- /dev/null +++ b/data/fixtures/scopes/markdown/collectionItem.unenclosed.scope @@ -0,0 +1,69 @@ +- This is the first level of a list. + - This is the second level of a list. +- This is the first level of a list again. +--- + +[#1 Content] = 0:2-1:39 + >---------------------------------- +0| - This is the first level of a list. +1| - This is the second level of a list. + ---------------------------------------< + +[#1 Removal] = 0:0-2:0 + >------------------------------------ +0| - This is the first level of a list. +1| - This is the second level of a list. +2| - This is the first level of a list again. + < + +[#1 Trailing delimiter] = 1:39-2:0 + > +1| - This is the second level of a list. +2| - This is the first level of a list again. + < + +[#1 Domain] = 0:0-1:39 + >------------------------------------ +0| - This is the first level of a list. +1| - This is the second level of a list. + ---------------------------------------< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = 1:4-1:39 + >-----------------------------------< +1| - This is the second level of a list. + +[#2 Removal] = 1:0-1:39 + >---------------------------------------< +1| - This is the second level of a list. + +[#2 Leading delimiter] = 1:0-1:2 + >--< +1| - This is the second level of a list. + +[#2 Domain] = 1:2-1:39 + >-------------------------------------< +1| - This is the second level of a list. + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = 2:2-2:42 + >----------------------------------------< +2| - This is the first level of a list again. + +[#3 Removal] = 2:0-2:42 + >------------------------------------------< +2| - This is the first level of a list again. + +[#3 Leading delimiter] = 2:0-2:0 + >< +2| - This is the first level of a list again. + +[#3 Domain] = 2:0-2:42 + >------------------------------------------< +2| - This is the first level of a list again. + +[#3 Insertion delimiter] = "\n" diff --git a/packages/common/src/scopeSupportFacets/markdown.ts b/packages/common/src/scopeSupportFacets/markdown.ts index 7831a7c036..4577880d5b 100644 --- a/packages/common/src/scopeSupportFacets/markdown.ts +++ b/packages/common/src/scopeSupportFacets/markdown.ts @@ -9,4 +9,5 @@ export const markdownScopeSupport: LanguageScopeSupportFacetMap = { "comment.block": supported, section: supported, notebookCell: supported, + "collectionItem.unenclosed": supported, }; diff --git a/queries/markdown.scm b/queries/markdown.scm index 1f33979a6f..95a0c82632 100644 --- a/queries/markdown.scm +++ b/queries/markdown.scm @@ -24,22 +24,17 @@ ;;! ^ ;;! --- (list - (list_item - (paragraph - (inline) @_.leading.endOf - ) - )? + (list_item)? @collectionItem.leading.endOf . (list_item - (_) @_.prefix - (paragraph - (inline) @collectionItem - ) - ) @_.domain + (_) @collectionItem.prefix + (paragraph) @collectionItem.start.startOf + ) @collectionItem.end.endOf @collectionItem.domain . - (list_item)? @_.trailing.startOf - (#trim-end! @_.domain) - (#insertion-delimiter! @collectionItem "\n") + (list_item)? @collectionItem.trailing.startOf + (#trim-end! @collectionItem.end.endOf) + (#trim-end! @collectionItem.domain) + (#insertion-delimiter! @collectionItem.start.startOf "\n") ) (list) @collectionItem.iteration