From 39a126ab7511fcb81bfb41a1ba974a6dc2b510df Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Thu, 19 Dec 2024 12:46:00 -0500 Subject: [PATCH] [Diff] Support multiline email headers --- Git Formats/Git Diff.sublime-syntax | 15 +++++++++++---- Git Formats/tests/syntax_test_git_diff.patch | 4 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 21abd3457e..72a6f22312 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -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: @@ -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)(:) @@ -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 @@ -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(:) @@ -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 @@ -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: diff --git a/Git Formats/tests/syntax_test_git_diff.patch b/Git Formats/tests/syntax_test_git_diff.patch index 25ddfa4554..b07a9d0448 100644 --- a/Git Formats/tests/syntax_test_git_diff.patch +++ b/Git Formats/tests/syntax_test_git_diff.patch @@ -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 @@ -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