From debf44bdcae8ad00822276a4c8a927ea7f71a527 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 3 Jun 2023 11:11:06 +0200 Subject: [PATCH 1/3] [XML] Fix group punctuation scope This commit changes scopes of parentheses to `punctuation.section.group`. --- XML/XML.sublime-syntax | 12 ++++++------ XML/syntax_test_xml.xml | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/XML/XML.sublime-syntax b/XML/XML.sublime-syntax index 4cc315f20b..2bbd86fb0c 100644 --- a/XML/XML.sublime-syntax +++ b/XML/XML.sublime-syntax @@ -294,7 +294,7 @@ contexts: scope: constant.other.xml pop: 1 - match: \( - scope: punctuation.definition.group.begin.xml + scope: punctuation.section.group.begin.xml set: dtd-element-parens - include: dtd-constants - include: dtd-content-quoted @@ -302,10 +302,10 @@ contexts: dtd-element-parens: - meta_scope: meta.group.xml - match: \) - scope: punctuation.definition.group.end.xml + scope: punctuation.section.group.end.xml set: dtd-element-operator - match: \( - scope: punctuation.definition.group.begin.xml + scope: punctuation.section.group.begin.xml push: dtd-element-parens - match: '[*?+]' scope: keyword.operator.xml @@ -353,16 +353,16 @@ contexts: dtd-attlist-parens: - match: \( - scope: punctuation.definition.group.begin.xml + scope: punctuation.section.group.begin.xml push: dtd-attlist-parens-content dtd-attlist-parens-content: - meta_scope: meta.group.enumerated.xml - match: \) - scope: punctuation.definition.group.end.xml + scope: punctuation.section.group.end.xml pop: 1 - match: \| - scope: punctuation.separator.logical.xml + scope: punctuation.separator.xml - include: dtd-constants - include: entity - include: should-be-entity diff --git a/XML/syntax_test_xml.xml b/XML/syntax_test_xml.xml index 7b930d9da4..6ef5e56daf 100644 --- a/XML/syntax_test_xml.xml +++ b/XML/syntax_test_xml.xml @@ -740,7 +740,7 @@ ## ^^^^^^^ keyword.declaration.element ## ^ - keyword - variable ## ^^^^^^^^^ variable.other.element -## ^ punctuation.definition.group.begin +## ^ punctuation.section.group.begin ## ^^^^^^^ constant.other.placeholder ## ^ punctuation.separator ## ^^^ meta.string string.unquoted @@ -753,7 +753,7 @@ ## ^^^^^ variable.parameter ## ^ punctuation.terminator.parameter ## ^ punctuation.separator -## ^ punctuation.definition.group.begin +## ^ punctuation.section.group.begin ## ^ punctuation.definition.entity ## ^^^^^ constant.character.entity.named ## ^ punctuation.terminator.entity @@ -765,9 +765,9 @@ ## ^^^ punctuation.definition.entity ## ^^^^^^ constant.character.entity.hexadecimal ## ^ punctuation.terminator.entity -## ^ punctuation.definition.group.end +## ^ punctuation.section.group.end ## ^ keyword.operator -## ^ punctuation.definition.group.end +## ^ punctuation.section.group.end ## ^ keyword.operator ## ^ punctuation.definition.tag.end From 73b789208db58bfcc1a995a58a34ec2c9c6c35fe Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 3 Jun 2023 11:12:57 +0200 Subject: [PATCH 2/3] [XML] Add syntax based folding rules --- XML/Fold.tmPreferences | 108 +++++++++++++++++++++++++++++++++++++++++ XML/XML.sublime-syntax | 24 ++++++--- 2 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 XML/Fold.tmPreferences diff --git a/XML/Fold.tmPreferences b/XML/Fold.tmPreferences new file mode 100644 index 0000000000..8d31a539a5 --- /dev/null +++ b/XML/Fold.tmPreferences @@ -0,0 +1,108 @@ + + + + scope + text.xml, text.xml.dtd, text.xml.xsl + settings + + indentationFoldingEnabled + + foldScopes + + + + begin + comment.block punctuation.definition.comment.begin + end + comment.block punctuation.definition.comment.end + excludeTrailingNewlines + + + + + begin + punctuation.definition.string.begin + end + punctuation.definition.string.end + excludeTrailingNewlines + + + + + begin + punctuation.section.brackets.begin + end + punctuation.section.brackets.end + excludeTrailingNewlines + + + + + begin + punctuation.section.group.begin + end + punctuation.section.group.end + excludeTrailingNewlines + + + + + begin + meta.tag.sgml.cdata punctuation.definition.tag.begin.content + end + meta.tag.sgml.cdata punctuation.definition.tag + excludeTrailingNewlines + + + + + begin + meta.tag.sgml keyword.declaration + end + meta.tag.sgml punctuation.definition.tag + excludeTrailingNewlines + + + + + begin + meta.tag.preprocessor entity.name.tag + end + meta.tag.preprocessor punctuation.definition.tag + excludeTrailingNewlines + + + + + begin + meta.tag entity.name.tag + end + meta.tag punctuation.definition.tag + excludeTrailingNewlines + + + + + begin + meta.tag punctuation.definition.tag.end.opening + end + meta.tag punctuation.definition.tag.begin.closing + excludeTrailingNewlines + + + + + + diff --git a/XML/XML.sublime-syntax b/XML/XML.sublime-syntax index 2bbd86fb0c..f36d09917a 100644 --- a/XML/XML.sublime-syntax +++ b/XML/XML.sublime-syntax @@ -156,11 +156,15 @@ contexts: ###[ CDATA ]################################################################## cdata: + # Notes: + # + # `content` sub-scope is used for folding. + # Changing it might cause folding to break! - match: ( - scope: punctuation.definition.tag.end.xml + - match: /> + scope: punctuation.definition.tag.end.self-closing.xml + pop: 1 + - match: '>' + scope: punctuation.definition.tag.end.opening.xml pop: 1 - match: \?> scope: invalid.illegal.bad-tag-end.xml @@ -587,7 +599,7 @@ contexts: end-tag-content: - meta_scope: meta.tag.xml - match: '>' - scope: punctuation.definition.tag.end.xml + scope: punctuation.definition.tag.end.closing.xml pop: 1 - include: tag-end-missing-pop - match: '[/\?]>' From 68d7399987e9a44643e8142372050a5efec989cf Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 25 Jul 2023 14:07:34 +0200 Subject: [PATCH 3/3] [XML] Fix folding of tags with fully qualified names This commit fixes an issue, which confused syntax based folding, if fully qualified tag names are involved. ```xml ``` --- XML/Fold.tmPreferences | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XML/Fold.tmPreferences b/XML/Fold.tmPreferences index 8d31a539a5..20d8460228 100644 --- a/XML/Fold.tmPreferences +++ b/XML/Fold.tmPreferences @@ -87,7 +87,7 @@ Note: Works only if closing punctuation is already on a separate line. --> begin - meta.tag entity.name.tag + meta.tag entity.name.tag.localname end meta.tag punctuation.definition.tag excludeTrailingNewlines