Skip to content

Commit

Permalink
[Diff] Support multiline email headers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelblyons committed Dec 19, 2024
1 parent 98fa1f8 commit 39a126a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 11 additions & 4 deletions Git Formats/Git Diff.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ contexts:
email-header-person-body:
- meta_scope: meta.mapping.diff
- include: scope:text.git.mailmap
# The mailmap include has bad interactions with
# pop-before-next-email-header
- include: pop-before-eol

email-header-commit:
Expand All @@ -88,7 +90,7 @@ contexts:
- meta_scope: meta.mapping.diff
- match: '{{git_hash}}'
scope: constant.other.hash.git
- include: pop-before-eol
- include: pop-before-next-email-header

email-header-subject-line:
- match: ^(Subject)(:)
Expand All @@ -101,7 +103,7 @@ contexts:
- meta_scope: meta.mapping.diff
- meta_content_scope: markup.heading.diff
- include: patch-annotation
- include: pop-before-eol
- include: pop-before-next-email-header

patch-annotation:
- match: (\[)(?:(RFC) )?PATCH
Expand Down Expand Up @@ -149,7 +151,7 @@ contexts:
2: punctuation.separator.date.diff
3: punctuation.separator.date.diff
4: storage.modifier.diff
- include: pop-before-eol
- include: pop-before-next-email-header

email-header-generic:
- match: ^\b([\w-]+)\b(:)
Expand All @@ -160,7 +162,7 @@ contexts:

email-header-generic-body:
- meta_scope: meta.mapping.diff
- include: pop-before-eol
- include: pop-before-next-email-header

email-body:
- meta_content_scope: meta.block.git-body.diff
Expand Down Expand Up @@ -542,6 +544,11 @@ contexts:
- match: ^{{next_diff_header}}
pop: 1

pop-before-next-email-header:
# Hack in `\` to support unit tests
- match: ^(?! \S|\\)
pop: 1

###############################################################################

variables:
Expand Down
4 changes: 3 additions & 1 deletion Git Formats/tests/syntax_test_git_diff.patch
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Date: Tue, 13 Jul 2010 11:42:54 -0700
\ ^ punctuation.separator.date.diff
\ ^ punctuation.separator.date.diff
\ ^^^^^ storage.modifier.diff
Subject: [PATCH v2 1/2] [IA64] Put ia64 config files on the Uwe Kleine-Koenig diet
Subject: [PATCH v2 1/2] [IA64] Put ia64 config files on the Uwe Kleine-Koenig
\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff
\ ^^ meta.annotation.patch-version.diff storage.modifier.diff
\ ^^^ meta.annotation.patch-sequence.diff
Expand All @@ -36,6 +36,8 @@ Subject: [PATCH v2 1/2] [IA64] Put ia64 config files on the Uwe Kleine-Koenig di
\ ^ punctuation.separator.sequence.diff
\ ^ meta.number.integer.decimal.diff constant.numeric.value.diff
\ ^ punctuation.definition.annotation.end.diff
diet
\^^^^^ meta.block.git-header.diff meta.mapping.diff markup.heading.diff
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff
Expand Down

0 comments on commit 39a126a

Please sign in to comment.