Skip to content

Commit

Permalink
[Diff] Merge leading text with headers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelblyons committed Dec 16, 2024
1 parent 6826deb commit 9f604e9
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions Diff/Diff.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -30,56 +30,49 @@ contexts:
set: diffs

diffs:
- include: leading-text
- include: line-ranges
- include: headers
- include: deltas
- include: diff3-normal

###[ LEADING TEXT ]############################################################
###[ HEADERS ]#################################################################

headers:
- include: headers-context
- include: headers-unified

leading-text:
- match: ^(Index)(:)[ \t]*
# https://svnbook.red-bean.com/en/1.7/svn-book.html#svn.ref.svn.c.patch
- match: ^(={67}|={78}|_{67}){{eol}}
scope: meta.separator.diff
captures:
1: meta.mapping.key.diff keyword.other.diff
2: punctuation.separator.key-value.diff
push: index-body
- match: ^(Prereq)(:)[ \t]*
1: punctuation.separator.block.diff

# File headers from extensions and SVN
- match: |-
^(?x:(
Added | Copied | Deleted | Index | Modified
| Prereq | Property [ ] changes [ ] on
)(:)[ \t]*
captures:
1: meta.mapping.key.diff keyword.other.diff
2: punctuation.separator.key-value.diff
push: prereq-body

index-body:
- meta_scope: meta.mapping.diff meta.diff.index meta.index.diff
- meta_content_scope: meta.mapping.value.diff meta.toc-list.file-name.diff
- include: pop-eol
- include: path-separators

prereq-body:
- meta_scope: meta.mapping.diff
- meta_content_scope: meta.mapping.value.diff string.unquoted.diff
- include: pop-eol
- include: path-separators

###[ HEADERS ]#################################################################
push: header-index-file-body
headers:
- include: headers-context
- include: headers-unified
# Can't find documentation for these "="-formatted headers, but there
# are preexisting unit tests.
- match: ^(={4}) .+(?= - )
scope: meta.diff.header.from-file meta.header.from-file.diff
captures:
1: punctuation.definition.from-file.diff
push: header-body
push: header-4equals-body

# Still not sure what this is, but there's a preexisting unit test
- match: ^(={67}){{eol}}
scope: meta.separator.diff
captures:
1: punctuation.separator.block.diff
header-index-file-body:
- meta_scope: meta.mapping.diff meta.diff.index meta.index.diff
- meta_content_scope: meta.mapping.value.diff meta.toc-list.file-name.diff
- include: pop-eol
- include: path-separators

header-body:
header-4equals-body:
- match: '( (-) )(.* (={4})){{eol}}'
captures:
1: meta.header.diff
Expand Down Expand Up @@ -140,13 +133,20 @@ contexts:
- include: dev-null
- include: path-separators
- include: date
- include: headers-unified-file-comment

headers-unified-to-file:
- meta_scope: meta.diff.header.to-file meta.header.to-file.diff
- include: pop-eol
- include: dev-null
- include: path-separators
- include: date
- include: headers-unified-file-comment

headers-unified-file-comment:
- match: \s+(\(.+\))(?=$)
captures:
1: comment.block.diff

###[ RANGES ]##################################################################

Expand Down

0 comments on commit 9f604e9

Please sign in to comment.