From 06e3966a19d4c56d86771e28ac1ee0d710941cd9 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:03 -0500 Subject: [PATCH 001/127] [Diff] Support alt mode for Git's "patch email" --- Diff/Diff.sublime-syntax | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 2856da0f85..9f02c55f25 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -14,11 +14,41 @@ first_line_match: |- |\*\*\*.*\d{4}\s*$ |\d+(,\d+)* (a|d|c) \d+(,\d+)* $ |diff\ --git[ ] + |From \h{40} Mon Sep 17 00:00:00 2001 ) +variables: + git_first_line: (?:From \h{40} Mon Sep 17 00:00:00 2001) + scope: source.diff contexts: + main: + - match: ^(?={{git_first_line}}) + push: git-first-line + - include: diff + + git-first-line: + - meta_content_scope: comment.line.diff + - match: \h{40} + scope: entity.name.git.diff + - match: \n|$ + set: git-email-header + + git-email-header: + - meta_scope: meta.block.git-header.diff + - match: ^\b([\w-]+)\b(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: + - meta_scope: meta.mapping.diff + - match: (?=$) + pop: 1 + - match: ^(?=\r?\n) + pop: 1 + + diff: - match: '^((\*{15})|(={67})|(-{3}))$\n?' scope: meta.separator.diff captures: From b4d9e96bc1e2dac675e0c08854d1e7b8959734c9 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:03 -0500 Subject: [PATCH 002/127] [Diff] Add special Git email headers --- Diff/Diff.sublime-syntax | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 9f02c55f25..3e37f67768 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -19,6 +19,8 @@ first_line_match: |- variables: git_first_line: (?:From \h{40} Mon Sep 17 00:00:00 2001) + day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) + month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) scope: source.diff contexts: @@ -37,6 +39,66 @@ contexts: git-email-header: - meta_scope: meta.block.git-header.diff + - match: |- + (?x: + ^( + From | To | Author | Committer | + Co-authored-by | + Signed-off-by | + Reviewed-by | + Acked-by | + Helped-by + ) + (:) + ) + captures: + 1: keyword + 2: punctuation.separator.mapping.key-value.diff + push: + - meta_scope: meta.mapping.diff + - include: scope:text.git.mailmap + - match: (?=$) + pop: 1 + - match: ^(Subject)(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: + - meta_scope: meta.mapping.diff + - meta_content_scope: entity.name.label.diff + - match: (\[)PATCH + captures: + 1: punctuation.definition.annotation.begin.diff + push: + - meta_scope: variable.annotation.diff + - match: \] + scope: punctuation.definition.annotation.end.diff + pop: 1 + - match: \bv\d+\b + scope: meta.annotation.patch-version.diff storage.modifier.diff + - match: (\d+)(/)(\d+) + scope: meta.annotation.patch-sequence.diff + captures: + 1: meta.number.integer.decimal.diff constant.numeric.value.diff + 2: punctuation.separator.sequence.diff + 3: meta.number.integer.decimal.diff constant.numeric.value.diff + - match: (?=$) + pop: 1 + - match: ^((?:Author|Committer)?Date)(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: + - meta_scope: meta.mapping.diff + - match: '{{day3}}(,) [0-3]?\d {{month3}} \d{4} \d\d(:)\d\d(:)\d\d(?: ([+-])\d{4})?' + scope: constant.numeric.value.diff + captures: + 1: punctuation.separator.sequence.diff + 2: punctuation.separator.sequence.diff + 3: punctuation.separator.sequence.diff + 4: keyword.operator.arithmetic.diff + - match: (?=$) + pop: 1 - match: ^\b([\w-]+)\b(:) captures: 1: keyword.other.diff From 3cf1c25daa3161c869df34f8b2d6e8ff55fb936a Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 003/127] [Diff] Add a Git --stat block --- Diff/Diff.sublime-syntax | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 3e37f67768..2e7b1ecc46 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -107,6 +107,31 @@ contexts: - meta_scope: meta.mapping.diff - match: (?=$) pop: 1 + - match: ^(?=\r?\n) + set: git-maybe-stat + + git-maybe-stat: + - match: ---\n + scope: punctuation.definition.section.diff + set: git-stat + - match: (?=\S) + pop: 1 + + git-stat: + - match: ^ (?=([^|]+\s+)\|) + push: + - match: .+?(?=\s+\|) + scope: entity.name.diff + - match: \| + scope: punctuation.separator.sequence.diff + - match: \d+ + scope: meta.number.integer.decimal.diff constant.numeric.value.diff + - match: \++ + scope: markup.inserted.diff + - match: -+ + scope: markup.deleted.diff + - match: (?=\n|$) + pop: 1 - match: ^(?=\r?\n) pop: 1 From 108b07212c27ab6b9bde81bec6da02dac116ba34 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 004/127] [Diff] Add binary files to --stat block --- Diff/Diff.sublime-syntax | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 2e7b1ecc46..a259c8ba54 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -124,6 +124,13 @@ contexts: scope: entity.name.diff - match: \| scope: punctuation.separator.sequence.diff + - match: (Bin) (\d+) (->) (\d+) (bytes) + captures: + 1: storage.type.diff + 2: meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff + 3: keyword.operator.logical.diff + 4: meta.number.integer.decimal.diff constant.numeric.value.diff + 5: constant.numeric.suffix.diff - match: \d+ scope: meta.number.integer.decimal.diff constant.numeric.value.diff - match: \++ @@ -190,3 +197,5 @@ contexts: captures: 1: punctuation.separator.key-value.diff 2: meta.toc-list.file-name.diff + - match: ^\\ No newline at end of file + scope: comment.line.diff From c2b04b3e8b68edf2993fb2b3f06bc864db51700d Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 005/127] [Diff] Add a Git --shortstat block --- Diff/Diff.sublime-syntax | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index a259c8ba54..cc5a45f714 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -118,10 +118,15 @@ contexts: pop: 1 git-stat: - - match: ^ (?=([^|]+\s+)\|) + - match: ^ (?=([^|]+[ ]+)\|) push: - - match: .+?(?=\s+\|) - scope: entity.name.diff + - match: (?=\S.+\|) + push: + - meta_content_scope: entity.name.diff + - match: (?=[ ]+\|) + pop: 1 + - match: /|\\ + scope: punctuation.separator.sequence.diff - match: \| scope: punctuation.separator.sequence.diff - match: (Bin) (\d+) (->) (\d+) (bytes) @@ -139,6 +144,24 @@ contexts: scope: markup.deleted.diff - match: (?=\n|$) pop: 1 + - match: ^(?= \d+ file) + push: + - match: $ + pop: 1 + - match: \d+ + scope: meta.number.integer.decimal.diff constant.numeric.value.diff + - match: ',' + scope: punctuation.separator.sequence.diff + - match: insertions?(\()\+(\)) + scope: markup.inserted.diff + captures: + 1: punctuation.definition.diff + 2: punctuation.definition.diff + - match: deletions?(\()-(\)) + scope: markup.deleted.diff + captures: + 1: punctuation.definition.diff + 2: punctuation.definition.diff - match: ^(?=\r?\n) pop: 1 From 2aa8ec9724266202fb9cf3f2859516b31772f278 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 006/127] [Diff] Add create/delete files to --shortstat Also include their file modes [Diff] Change file mode highlighting [Diff] Loosen file mode match --- Diff/Diff.sublime-syntax | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index cc5a45f714..33214a047b 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -65,7 +65,7 @@ contexts: 2: punctuation.separator.mapping.key-value.diff push: - meta_scope: meta.mapping.diff - - meta_content_scope: entity.name.label.diff + - meta_content_scope: markup.heading.diff - match: (\[)PATCH captures: 1: punctuation.definition.annotation.begin.diff @@ -127,6 +127,8 @@ contexts: pop: 1 - match: /|\\ scope: punctuation.separator.sequence.diff + - match: \.{3} + scope: keyword.operator.diff - match: \| scope: punctuation.separator.sequence.diff - match: (Bin) (\d+) (->) (\d+) (bytes) @@ -134,7 +136,7 @@ contexts: 1: storage.type.diff 2: meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff 3: keyword.operator.logical.diff - 4: meta.number.integer.decimal.diff constant.numeric.value.diff + 4: meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff 5: constant.numeric.suffix.diff - match: \d+ scope: meta.number.integer.decimal.diff constant.numeric.value.diff @@ -162,9 +164,27 @@ contexts: captures: 1: punctuation.definition.diff 2: punctuation.definition.diff + - match: ^ (?=create mode) + push: + - meta_content_scope: markup.inserted.diff + - include: inside-create-delete-mode + - match: ^ (?=delete mode) + push: + - meta_content_scope: markup.deleted.diff + - include: inside-create-delete-mode - match: ^(?=\r?\n) pop: 1 + inside-create-delete-mode: + - match: \b(?:100)?644\b + scope: meta.number.integer.octal.diff constant.numeric.value.diff + - match: \b(?:100)?755\b + scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.diff + - match: /|\\ + scope: punctuation.separator.sequence.diff + - match: (?=$) + pop: 1 + diff: - match: '^((\*{15})|(={67})|(-{3}))$\n?' scope: meta.separator.diff From a365452cbcf32aabe58a05e15c96530a5f2009e4 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 007/127] [Diff] Add/Move test files --- Diff/{ => tests}/syntax_test_diff.diff | 9 +- Diff/tests/syntax_test_git_diff.patch | 135 +++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 1 deletion(-) rename Diff/{ => tests}/syntax_test_diff.diff (92%) create mode 100644 Diff/tests/syntax_test_git_diff.patch diff --git a/Diff/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff similarity index 92% rename from Diff/syntax_test_diff.diff rename to Diff/tests/syntax_test_diff.diff index e2e0550f6f..2def567589 100644 --- a/Diff/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -35,6 +35,13 @@ # ^^^^^^^^^^^^^^^^^^^^^^ entity.name.section.diff # ^ - entity.name.section.diff +==== Something - Else ==== +#^^^^^^^^^^^^^ meta.header.from-file.diff +#^^^ punctuation.definition.from-file.diff +# ^^^^^^^^^^^^ meta.header.to-file.diff +# ^ punctuation.definition.to-file.diff +# ^^^^ punctuation.definition.to-file.diff + --- Range ---- #^^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff # <- punctuation.definition.range.diff @@ -68,7 +75,7 @@ #^^^ -punctuation.definition.separator.diff Plain Text -#^^^^^^^^^ source.diff +#^^^^^^^^^ source.diff - markup + Addition # <- markup.inserted.diff punctuation.definition.inserted.diff diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch new file mode 100644 index 0000000000..5f7de4cf59 --- /dev/null +++ b/Diff/tests/syntax_test_git_diff.patch @@ -0,0 +1,135 @@ +# SYNTAX TEST "Packages/Diff/Diff.sublime-syntax" +From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001 +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.diff +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.git.diff +From: Tony Luck +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.diff +#^^^ keyword +# ^ punctuation.separator.mapping.key-value.diff +# ^^^^^^^^^ meta.reference.user.git +# ^^^^^^^^^^^^^^^^^^^^^ meta.reference.email.git +# ^ punctuation.definition.reference.email.begin.git +# ^^^^^^^^^^^^^^^^^^^ entity.name.reference.email.git +# ^ punctuation.separator.email.git +# ^ punctuation.separator.domain.git +# ^ punctuation.definition.reference.email.end.git +Date: Tue, 13 Jul 2010 11:42:54 -0700 +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff +#^^^ keyword +# ^ punctuation.separator.mapping.key-value.diff +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.numeric.value.diff +# ^ punctuation.separator.sequence.diff +# ^ punctuation.separator.sequence.diff +# ^ punctuation.separator.sequence.diff +# ^ keyword.operator.arithmetic.diff +Subject: [PATCH 1/2] [IA64] Put ia64 config files on the Uwe Kleine-Koenig diet +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff +#^^^^^^ keyword +# ^ punctuation.separator.mapping.key-value.diff +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.diff +# ^^^^^^^^^^^ variable.annotation.diff +# ^ punctuation.definition.annotation.begin.diff +# ^ meta.number.integer.decimal.diff constant.numeric.value.diff +# ^ punctuation.separator.sequence.diff +# ^ meta.number.integer.decimal.diff constant.numeric.value.diff +# ^ punctuation.definition.annotation.end.diff +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff +#^^^^^^^^^^^ keyword.other.diff +Content-Transfer-Encoding: 8bit + +arch/arm config files were slimmed down using a python script + +(See commit c2330e286f68f1c408b4aa6515ba49d57f05beae comment) +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git + +Do the same for ia64 so we can have sleek & trim looking + +--- + Gemfile | 1 + +#^^^^^^^ entity.name.diff +# ^ punctuation.separator.sequence.diff +# ^ meta.number.integer.decimal.diff constant.numeric.value.diff +# ^ markup.inserted.diff + app/assets/images/logo.jpeg | Bin 0 -> 50966 bytes +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.diff +# ^ punctuation.separator.sequence.diff +# ^ punctuation.separator.sequence.diff +# ^ punctuation.separator.sequence.diff +# ^ punctuation.separator.sequence.diff +# ^^^ storage.type.diff +# ^ meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff +# ^^ keyword.operator.logical.diff +# ^^^^^ meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff +# ^^^^^ constant.numeric.suffix.diff + fonts/icomoon.eot | Bin 55452 -> 56000 bytes + 3 files changed, 1 insertion(+) +#^ meta.number.integer.decimal.diff constant.numeric.value.diff +# ^ punctuation.separator.sequence.diff +# ^ meta.number.integer.decimal.diff constant.numeric.value.diff +# ^^^^^^^^^^^^ markup.inserted.diff +# ^ punctuation.definition.diff +# ^ punctuation.definition.diff + +diff --git a/Gemfile b/Gemfile +index c661619..989efe8 100644 +--- a/Gemfile ++++ b/Gemfile +@@ -24,6 +24,7 @@ group :development do + gem 'listen', '~> 3.0.5' + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' ++ gem 'rspec-rails' + end + + gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +diff --git a/app/assets/images/logo.jpeg b/app/assets/images/logo.jpeg +new file mode 100644 +index 0000000000000000000000000000000000000000..064fa38be3ecd426a3c8977ed43df627c6f6f229 +GIT binary patch +literal 50966 +zcmbT6RZtv2x1a}i2o6CLAUMHc&=7(LcbCE49fAa#;4l!}9R?j7La@Qz-3jh4+5Goz +z?N;s6?w*#Hmg=v%T8{i(_`3mkBQGr{4M0Eu01*Bqz~5JZu%w!lgod)35UrItyREZ@ +zetc_etc_(hundreds_of_lines) +z_i{8b#lS>d00-gEau-UmipEYM(5_o#RQj_ZJv9|UY@uA|M&a- +z-#$F6-;kv%Bvq;)#8s9kMe~?~lS^$MkZ)X4mTqx{`@;`ELI}+Er-zU +zUl2md1SWJF6ob$m4rAZM)XZ#OgtsGE?L8tCvF<&*1n|)5r5Oh{OuI|5sH(-)mvFIXhzEU8N +z@nwnJB-fDvSrO8KR|jq#$oK_X1esyM3&aTI)9TfiNWBZE)Dvmw1q(E(Qzr!V#_1OV +zBu}fGgb}_}=i$8<->JJ{QOy(Giwcy~b8$5Y?;}K@PTXgWETK8Hgl7zaD2O2_h=O;Q +zC+wkUwiVd +z_8-#%I8DI?w_1xdC5Qz2&eFK1qr~R0^kkKBt|r +z*l8MortKES?)3T6VJwb)94`or#XwPpx{l^2{(S`T+TI#7-Oy~U>49Gf5+VVAi`f)z +zmb_MmspadnB%wXpEwIhQsI64C+o)z+Ps0kn*Q&zIs6(tr2Xo+!MO{~=K;~gBY +z$BXAU-YtrQvK)`g@}MZXtBhXX07_hF^1sRRPJf5(9w9V3qZ-g^M}35w!(O}Jag95~%{hN^4Q&5n#|8H_&yU_AUx~jg%r(C2-x*w!p2};{ +zU9mIqjl^%e|Jajg|Fk33+0%97^^5y1>~G!wJV_<5r+T^*2PO|4?7et+=*ZbVs{i@G +vrJ>4OeEIG6k=hKGSs#6ty)`yHzHs!xL@3vqJCl3zj(|r8eEW-)I~(vf1`5_3~K=WNjf@&kbC+Y0iFOBk4eG7Q&&&S6ksU}l+| +z%-F-oI{5>mIy-~t4$+OG-J9i@jtg%7D?0grjAd55Z#=)vR|am7^$ZMmcTV^QqbIMq +zX3iKk`N=iy&EnUc8SA-c@j38?@MZAT2qp=B6Z$5+M1(_Rk*J+mg1DcAg`}L+25C3x +zGMQttesXi Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 008/127] [Diff] Add context for email body with formatting Includes the Git Commit Message stuff, because that's what it is. --- Diff/Diff.sublime-syntax | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 33214a047b..42ccee1fd8 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -108,10 +108,16 @@ contexts: - match: (?=$) pop: 1 - match: ^(?=\r?\n) + set: git-email-body + + git-email-body: + - meta_content_scope: meta.block.git-body.diff + - match: ^(?=---\r?\n) set: git-maybe-stat + - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message git-maybe-stat: - - match: ---\n + - match: ---\r?\n scope: punctuation.definition.section.diff set: git-stat - match: (?=\S) From b06d2d3a69d79e7cb418374b0131f7e6505d5871 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 009/127] [Diff] Split to Git, other, and common contexts --- Diff/Diff.sublime-syntax | 95 +++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 31 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 42ccee1fd8..2fe0503f35 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -128,7 +128,7 @@ contexts: push: - match: (?=\S.+\|) push: - - meta_content_scope: entity.name.diff + - meta_content_scope: meta.toc-list.filename.diff entity.name.diff - match: (?=[ ]+\|) pop: 1 - match: /|\\ @@ -191,13 +191,8 @@ contexts: - match: (?=$) pop: 1 - diff: - - match: '^((\*{15})|(={67})|(-{3}))$\n?' - scope: meta.separator.diff - captures: - 1: punctuation.definition.separator.diff - - match: ^\d+(,\d+)*(a|d|c)\d+(,\d+)*$\n? - scope: meta.diff.range.normal meta.range.normal.diff + + diff-common: - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*$\n? scope: meta.diff.range.unified meta.range.unified.diff captures: @@ -205,46 +200,84 @@ contexts: 2: meta.toc-list.line-number.diff 3: punctuation.definition.range.diff 4: entity.name.section.diff - - match: '^(((\-{3}) .+ (\-{4}))|((\*{3}) .+ (\*{4})))$\n?' - scope: meta.diff.range.context meta.range.context.diff - captures: - 3: punctuation.definition.range.diff - 4: punctuation.definition.range.diff - 6: punctuation.definition.range.diff - 7: punctuation.definition.range.diff - - match: '(^(((-{3}) .+)|((\*{3}) .+))$\n?|^(={4}) .+(?= - ))' + - match: ^-{3}$\n? + scope: meta.separator.diff punctuation.definition.separator.diff + - match: ^(-{3}) .+$\n? scope: meta.diff.header.from-file meta.header.from-file.diff captures: - 4: punctuation.definition.from-file.diff - 6: punctuation.definition.from-file.diff - 7: punctuation.definition.from-file.diff - - match: '(^(\+{3}) .+$\n?| (-) .* (={4})$\n?)' + 1: punctuation.definition.from-file.diff + - match: ^(\+{3}) .+$\n? scope: meta.diff.header.to-file meta.header.to-file.diff captures: - 2: punctuation.definition.to-file.diff - 3: punctuation.definition.to-file.diff - 4: punctuation.definition.to-file.diff - - match: ^(?:(>)(?:\ .*?)?|(\+).*?)(\s*?)$\n? + 1: punctuation.definition.to-file.diff + - match: ^(\+).*?(\s*?)$\n? scope: markup.inserted.diff captures: 1: punctuation.definition.inserted.diff - 2: punctuation.definition.inserted.diff - 3: meta.whitespace.trailing.diff + 2: meta.whitespace.trailing.diff + - match: ^(-).*?(\s*?)$\n? + scope: markup.deleted.diff + captures: + 1: punctuation.definition.deleted.diff + 2: meta.whitespace.trailing.diff + - match: ^\\ No newline at end of file + scope: comment.line.diff + + # TODO: ours/theirs parent diff + # TODO: git-style binary + diff-git: [] + + diff-generic: + - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*$\n? + scope: meta.diff.range.normal meta.range.normal.diff + captures: + 1: punctuation.separator.sequence.diff + 2: markup.inserted.diff + 3: markup.deleted.diff + 4: markup.changed.diff + - match: ^(?:(-{3}) .+ (-{4})|(\*{3}) .+ (\*{4}))$\n? + scope: meta.diff.range.context meta.range.context.diff + captures: + 1: punctuation.definition.range.diff + 2: punctuation.definition.range.diff + 3: punctuation.definition.range.diff + 4: punctuation.definition.range.diff + - match: ^(\*{15}|={67})$\n? + scope: meta.separator.diff + captures: + 1: punctuation.definition.separator.diff - match: ^(!).*?(\s*?)$\n? scope: markup.changed.diff captures: 1: punctuation.definition.changed.diff 2: meta.whitespace.trailing.diff - - match: ^(?:(<)(?:\ .*?)?|(-).*?)(\s*?)$\n? + - match: ^(>).*?(\s*?)$\n? + scope: markup.inserted.diff + captures: + 1: punctuation.definition.inserted.diff + 2: meta.whitespace.trailing.diff + - match: ^(<).*?(\s*?)$\n? scope: markup.deleted.diff captures: 1: punctuation.definition.deleted.diff - 2: punctuation.definition.deleted.diff - 3: meta.whitespace.trailing.diff + 2: meta.whitespace.trailing.diff + - match: ^(?:(\*{3}) .+)$\n?|^(={4}) .+(?= - ) + scope: meta.diff.header.from-file meta.header.from-file.diff + captures: + 1: punctuation.definition.from-file.diff + 2: punctuation.definition.from-file.diff + - match: ' (-) .* (={4})$\n?' + scope: meta.diff.header.to-file meta.header.to-file.diff + captures: + 1: punctuation.definition.to-file.diff + 2: punctuation.definition.to-file.diff - match: ^Index(:) (.+)$\n? scope: meta.diff.index meta.index.diff captures: 1: punctuation.separator.key-value.diff 2: meta.toc-list.file-name.diff - - match: ^\\ No newline at end of file - scope: comment.line.diff + + diff: + - include: diff-git + - include: diff-generic + - include: diff-common From ad2984911a2648f0e51fa2f491d702f1e4575f12 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 010/127] [Diff] Add Git binary patch format [Diff] Empty file hash --- Diff/Diff.sublime-syntax | 22 +++++++++++++++++++--- Diff/tests/syntax_test_git_diff.patch | 6 +++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 2fe0503f35..29fae4e793 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -21,6 +21,7 @@ variables: git_first_line: (?:From \h{40} Mon Sep 17 00:00:00 2001) day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) + base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' scope: source.diff contexts: @@ -191,7 +192,6 @@ contexts: - match: (?=$) pop: 1 - diff-common: - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*$\n? scope: meta.diff.range.unified meta.range.unified.diff @@ -224,8 +224,24 @@ contexts: scope: comment.line.diff # TODO: ours/theirs parent diff - # TODO: git-style binary - diff-git: [] + diff-git: + - match: GIT binary patch + scope: keyword.other.diff + push: + - match: ^(delta|literal) (\d+) + captures: + 1: support.function.diff + 2: meta.number.integer.decimal.diff constant.numeric.value.diff + - match: ^(H)cmV\?d00001$ + scope: constant.language.null.diff + captures: + 1: punctuation.definition.string.begin.diff + - match: ^([A-Za-z]){{base85}}{1,66}$ + scope: meta.string.diff string.other.raw.diff + captures: + 1: punctuation.definition.string.begin.diff + - match: ^(?!(delta|literal|$)) + pop: 1 diff-generic: - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*$\n? diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index 5f7de4cf59..1801b6f406 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -92,7 +92,11 @@ GIT binary patch literal 50966 zcmbT6RZtv2x1a}i2o6CLAUMHc&=7(LcbCE49fAa#;4l!}9R?j7La@Qz-3jh4+5Goz z?N;s6?w*#Hmg=v%T8{i(_`3mkBQGr{4M0Eu01*Bqz~5JZu%w!lgod)35UrItyREZ@ -zetc_etc_(hundreds_of_lines) +z----------------------------------------------------------------- +z----------------------------------------------------------------- +z-----------------(hundreds_of_lines_of_Base85)------------------- +z----------------------------------------------------------------- +z----------------------------------------------------------------- z_i{8b#lS>d00-gE Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 011/127] [Diff] Git file headings --- Diff/Diff.sublime-syntax | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 29fae4e793..8c145a528f 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -225,6 +225,21 @@ contexts: # TODO: ours/theirs parent diff diff-git: + - match: ^(diff) ((--)git) + captures: + 1: variable.function.diff + 2: variable.parameter.diff + 3: punctuation.definition.parameter.diff + - match: ^(index) (?:(0{1,40})|(\h{1,40}))\b(\.\.)(?:(0{1,40})|(\h{1,40}))\b + captures: + 1: keyword.other.diff + 2: markup.deleted.diff + 3: entity.name.git.diff + 4: punctuation.separator.sequence.diff + 5: markup.deleted.diff + 6: entity.name.git.diff + push: + - include: inside-create-delete-mode - match: GIT binary patch scope: keyword.other.diff push: From d0e546b30ceacaa39537086fa162e05247a163f5 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 012/127] [Diff] Fully split Git-special vs generic diffs --- Diff/Diff.sublime-syntax | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 8c145a528f..2be3ffd3d4 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -29,7 +29,7 @@ contexts: main: - match: ^(?={{git_first_line}}) push: git-first-line - - include: diff + - include: diff-generic git-first-line: - meta_content_scope: comment.line.diff @@ -180,7 +180,7 @@ contexts: - meta_content_scope: markup.deleted.diff - include: inside-create-delete-mode - match: ^(?=\r?\n) - pop: 1 + set: diff-git inside-create-delete-mode: - match: \b(?:100)?644\b @@ -257,6 +257,7 @@ contexts: 1: punctuation.definition.string.begin.diff - match: ^(?!(delta|literal|$)) pop: 1 + - include: diff-common diff-generic: - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*$\n? @@ -307,8 +308,4 @@ contexts: captures: 1: punctuation.separator.key-value.diff 2: meta.toc-list.file-name.diff - - diff: - - include: diff-git - - include: diff-generic - include: diff-common From e65528cd589efd6aba49aa8befa277706eb50584 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 013/127] [Diff] Tweak commit hash scope --- Diff/Diff.sublime-syntax | 6 +++--- Diff/tests/syntax_test_git_diff.patch | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 2be3ffd3d4..89e05287e4 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -34,7 +34,7 @@ contexts: git-first-line: - meta_content_scope: comment.line.diff - match: \h{40} - scope: entity.name.git.diff + scope: constant.other.hash.git - match: \n|$ set: git-email-header @@ -234,10 +234,10 @@ contexts: captures: 1: keyword.other.diff 2: markup.deleted.diff - 3: entity.name.git.diff + 3: constant.other.hash.git 4: punctuation.separator.sequence.diff 5: markup.deleted.diff - 6: entity.name.git.diff + 6: constant.other.hash.git push: - include: inside-create-delete-mode - match: GIT binary patch diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index 1801b6f406..40214b8bc9 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -1,7 +1,7 @@ # SYNTAX TEST "Packages/Diff/Diff.sublime-syntax" From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.diff -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.git.diff +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git From: Tony Luck #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.diff From 6c10828bc965d0fa5bdc384fbf919a07aa5bdafb Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 014/127] [Diff] Git diff end block Technically, this is called the "signature." --- Diff/Diff.sublime-syntax | 5 +++++ Diff/tests/syntax_test_git_diff.patch | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 89e05287e4..eb8f696293 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -225,6 +225,11 @@ contexts: # TODO: ours/theirs parent diff diff-git: + - match: ^(-- )$\r?\n? + captures: + 1: meta.separator.diff punctuation.definition.separator.diff + set: + - meta_content_scope: comment.block.diff - match: ^(diff) ((--)git) captures: 1: variable.function.diff diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index 40214b8bc9..bd5e44c7d7 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -135,5 +135,7 @@ zGMQttesXi Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 015/127] [Diff] Consolidate some variables --- Diff/Diff.sublime-syntax | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index eb8f696293..83e7be2945 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -18,14 +18,21 @@ first_line_match: |- ) variables: - git_first_line: (?:From \h{40} Mon Sep 17 00:00:00 2001) + commit_hash_full: \h{40} + commit_hash: \h{7,40} + git_first_line: (?:From {{commit_hash_full}} Mon Sep 17 00:00:00 2001) day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' + empty_line: ^(?=\r?\n) scope: source.diff contexts: + path-separators: + - match: /|\\ + scope: punctuation.separator.sequence.diff + main: - match: ^(?={{git_first_line}}) push: git-first-line @@ -33,7 +40,7 @@ contexts: git-first-line: - meta_content_scope: comment.line.diff - - match: \h{40} + - match: '{{commit_hash_full}}' scope: constant.other.hash.git - match: \n|$ set: git-email-header @@ -108,7 +115,7 @@ contexts: - meta_scope: meta.mapping.diff - match: (?=$) pop: 1 - - match: ^(?=\r?\n) + - match: '{{empty_line}}' set: git-email-body git-email-body: @@ -122,7 +129,7 @@ contexts: scope: punctuation.definition.section.diff set: git-stat - match: (?=\S) - pop: 1 + set: diff-git git-stat: - match: ^ (?=([^|]+[ ]+)\|) @@ -132,8 +139,7 @@ contexts: - meta_content_scope: meta.toc-list.filename.diff entity.name.diff - match: (?=[ ]+\|) pop: 1 - - match: /|\\ - scope: punctuation.separator.sequence.diff + - include: path-separators - match: \.{3} scope: keyword.operator.diff - match: \| @@ -179,7 +185,7 @@ contexts: push: - meta_content_scope: markup.deleted.diff - include: inside-create-delete-mode - - match: ^(?=\r?\n) + - match: '{{empty_line}}' set: diff-git inside-create-delete-mode: @@ -187,8 +193,7 @@ contexts: scope: meta.number.integer.octal.diff constant.numeric.value.diff - match: \b(?:100)?755\b scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.diff - - match: /|\\ - scope: punctuation.separator.sequence.diff + - include: path-separators - match: (?=$) pop: 1 @@ -235,7 +240,7 @@ contexts: 1: variable.function.diff 2: variable.parameter.diff 3: punctuation.definition.parameter.diff - - match: ^(index) (?:(0{1,40})|(\h{1,40}))\b(\.\.)(?:(0{1,40})|(\h{1,40}))\b + - match: ^(index) (?:(0{7,40})|({{commit_hash}}))\b(\.\.)(?:(0{7,40})|({{commit_hash}}))\b captures: 1: keyword.other.diff 2: markup.deleted.diff From 388d3f66f64467c2e5168a9b6132be1d47ec1e72 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 016/127] [Diff] File mode stuff --- Diff/Diff.sublime-syntax | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 83e7be2945..fc96a04ec9 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -207,14 +207,16 @@ contexts: 4: entity.name.section.diff - match: ^-{3}$\n? scope: meta.separator.diff punctuation.definition.separator.diff - - match: ^(-{3}) .+$\n? + - match: ^(-{3}) (?:(/dev/null)|.+)$\n? scope: meta.diff.header.from-file meta.header.from-file.diff captures: 1: punctuation.definition.from-file.diff - - match: ^(\+{3}) .+$\n? + 2: constant.language.null.diff + - match: ^(\+{3}) (?:(/dev/null)|.+)$\n? scope: meta.diff.header.to-file meta.header.to-file.diff captures: 1: punctuation.definition.to-file.diff + 2: constant.language.null.diff - match: ^(\+).*?(\s*?)$\n? scope: markup.inserted.diff captures: @@ -240,6 +242,14 @@ contexts: 1: variable.function.diff 2: variable.parameter.diff 3: punctuation.definition.parameter.diff + - match: ^(?=new file mode) + push: + - meta_content_scope: markup.inserted.diff + - include: inside-create-delete-mode + - match: ^(?=deleted file mode) + push: + - meta_content_scope: markup.deleted.diff + - include: inside-create-delete-mode - match: ^(index) (?:(0{7,40})|({{commit_hash}}))\b(\.\.)(?:(0{7,40})|({{commit_hash}}))\b captures: 1: keyword.other.diff From e5cd833702bb89d161d1ac2bef749f3595022e77 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 017/127] [Diff] Filename in git diff headers --- Diff/Diff.sublime-syntax | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index fc96a04ec9..db976728e0 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -1,7 +1,8 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html +# http://www.sublimetext.com/docs/syntax.html name: Diff +version: 2 file_extensions: - diff - patch @@ -28,6 +29,13 @@ variables: scope: source.diff contexts: + pop-eol: + - match: $|\r|\n + pop: 1 + + pop-before-eol: + - match: (?=$|\r|\n) + pop: 1 path-separators: - match: /|\\ @@ -134,6 +142,7 @@ contexts: git-stat: - match: ^ (?=([^|]+[ ]+)\|) push: + - include: pop-before-eol - match: (?=\S.+\|) push: - meta_content_scope: meta.toc-list.filename.diff entity.name.diff @@ -157,12 +166,9 @@ contexts: scope: markup.inserted.diff - match: -+ scope: markup.deleted.diff - - match: (?=\n|$) - pop: 1 - match: ^(?= \d+ file) push: - - match: $ - pop: 1 + - include: pop-eol - match: \d+ scope: meta.number.integer.decimal.diff constant.numeric.value.diff - match: ',' @@ -189,13 +195,12 @@ contexts: set: diff-git inside-create-delete-mode: + - include: pop-before-eol + - include: path-separators - match: \b(?:100)?644\b scope: meta.number.integer.octal.diff constant.numeric.value.diff - match: \b(?:100)?755\b scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.diff - - include: path-separators - - match: (?=$) - pop: 1 diff-common: - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*$\n? @@ -242,6 +247,18 @@ contexts: 1: variable.function.diff 2: variable.parameter.diff 3: punctuation.definition.parameter.diff + push: + - include: pop-eol + - match: (a|b|ours|theirs)(/) + captures: + 1: constant.language.diff + 2: punctuation.separator.sequence.diff + push: + - meta_scope: entity.name.diff + - meta_content_scope: meta.toc-list.filename.diff + - match: (?=\s|$) + pop: 1 + - include: path-separators - match: ^(?=new file mode) push: - meta_content_scope: markup.inserted.diff From 77315894c1b6eadfb03208321cd1e526a360abac Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 018/127] [Diff] Refactor Git file header --- Diff/Diff.sublime-syntax | 55 ++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index db976728e0..390dfd490b 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -46,6 +46,7 @@ contexts: push: git-first-line - include: diff-generic + # https://git-scm.com/docs/git-format-patch git-first-line: - meta_content_scope: comment.line.diff - match: '{{commit_hash_full}}' @@ -235,7 +236,8 @@ contexts: - match: ^\\ No newline at end of file scope: comment.line.diff - # TODO: ours/theirs parent diff + # https://git-scm.com/docs/diff-format#generate_patch_text_with_p + # TODO: multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format diff-git: - match: ^(-- )$\r?\n? captures: @@ -259,24 +261,7 @@ contexts: - match: (?=\s|$) pop: 1 - include: path-separators - - match: ^(?=new file mode) - push: - - meta_content_scope: markup.inserted.diff - - include: inside-create-delete-mode - - match: ^(?=deleted file mode) - push: - - meta_content_scope: markup.deleted.diff - - include: inside-create-delete-mode - - match: ^(index) (?:(0{7,40})|({{commit_hash}}))\b(\.\.)(?:(0{7,40})|({{commit_hash}}))\b - captures: - 1: keyword.other.diff - 2: markup.deleted.diff - 3: constant.other.hash.git - 4: punctuation.separator.sequence.diff - 5: markup.deleted.diff - 6: constant.other.hash.git - push: - - include: inside-create-delete-mode + - include: diff-git-header-extended - match: GIT binary patch scope: keyword.other.diff push: @@ -296,6 +281,38 @@ contexts: pop: 1 - include: diff-common + # https://git-scm.com/docs/diff-format#generate_patch_text_with_p + diff-git-header-extended: + # old mode + # new mode + # deleted file mode + - match: ^(?=deleted file mode) + push: + - meta_content_scope: markup.deleted.diff + - include: inside-create-delete-mode + # new file mode + - match: ^(?=new file mode) + push: + - meta_content_scope: markup.inserted.diff + - include: inside-create-delete-mode + # copy from + # copy to + # rename from + # rename to + # similarity index + # dissimilarity index + # index .. + - match: ^(index) (?:(0{7,40})|({{commit_hash}}))\b(\.\.)(?:(0{7,40})|({{commit_hash}}))\b + captures: + 1: keyword.other.diff + 2: markup.deleted.diff + 3: constant.other.hash.git + 4: punctuation.separator.sequence.diff + 5: markup.deleted.diff + 6: constant.other.hash.git + push: + - include: inside-create-delete-mode + diff-generic: - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*$\n? scope: meta.diff.range.normal meta.range.normal.diff From 1e88e63a916a46ad496cd5edcd0c23ff52469f28 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 019/127] [Diff] Move Git Diff to its own file !!!!! --- Diff/Diff.sublime-syntax | 260 +---------------------- Diff/Git Diff.sublime-syntax | 284 ++++++++++++++++++++++++++ Diff/tests/syntax_test_git_diff.patch | 2 +- 3 files changed, 288 insertions(+), 258 deletions(-) create mode 100644 Diff/Git Diff.sublime-syntax diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 390dfd490b..5f6faffd35 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -1,6 +1,6 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/syntax.html +# https://www.sublimetext.com/docs/syntax.html name: Diff version: 2 file_extensions: @@ -14,195 +14,18 @@ first_line_match: |- |---\ [^%] |\*\*\*.*\d{4}\s*$ |\d+(,\d+)* (a|d|c) \d+(,\d+)* $ - |diff\ --git[ ] - |From \h{40} Mon Sep 17 00:00:00 2001 ) variables: - commit_hash_full: \h{40} - commit_hash: \h{7,40} - git_first_line: (?:From {{commit_hash_full}} Mon Sep 17 00:00:00 2001) - day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) - month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) - base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' - empty_line: ^(?=\r?\n) + git_first_line: (?:From \h{40} Mon Sep 17 00:00:00 2001) scope: source.diff contexts: - pop-eol: - - match: $|\r|\n - pop: 1 - - pop-before-eol: - - match: (?=$|\r|\n) - pop: 1 - - path-separators: - - match: /|\\ - scope: punctuation.separator.sequence.diff - main: - match: ^(?={{git_first_line}}) - push: git-first-line + push: Git Diff.sublime-syntax#email-first-line - include: diff-generic - # https://git-scm.com/docs/git-format-patch - git-first-line: - - meta_content_scope: comment.line.diff - - match: '{{commit_hash_full}}' - scope: constant.other.hash.git - - match: \n|$ - set: git-email-header - - git-email-header: - - meta_scope: meta.block.git-header.diff - - match: |- - (?x: - ^( - From | To | Author | Committer | - Co-authored-by | - Signed-off-by | - Reviewed-by | - Acked-by | - Helped-by - ) - (:) - ) - captures: - 1: keyword - 2: punctuation.separator.mapping.key-value.diff - push: - - meta_scope: meta.mapping.diff - - include: scope:text.git.mailmap - - match: (?=$) - pop: 1 - - match: ^(Subject)(:) - captures: - 1: keyword.other.diff - 2: punctuation.separator.mapping.key-value.diff - push: - - meta_scope: meta.mapping.diff - - meta_content_scope: markup.heading.diff - - match: (\[)PATCH - captures: - 1: punctuation.definition.annotation.begin.diff - push: - - meta_scope: variable.annotation.diff - - match: \] - scope: punctuation.definition.annotation.end.diff - pop: 1 - - match: \bv\d+\b - scope: meta.annotation.patch-version.diff storage.modifier.diff - - match: (\d+)(/)(\d+) - scope: meta.annotation.patch-sequence.diff - captures: - 1: meta.number.integer.decimal.diff constant.numeric.value.diff - 2: punctuation.separator.sequence.diff - 3: meta.number.integer.decimal.diff constant.numeric.value.diff - - match: (?=$) - pop: 1 - - match: ^((?:Author|Committer)?Date)(:) - captures: - 1: keyword.other.diff - 2: punctuation.separator.mapping.key-value.diff - push: - - meta_scope: meta.mapping.diff - - match: '{{day3}}(,) [0-3]?\d {{month3}} \d{4} \d\d(:)\d\d(:)\d\d(?: ([+-])\d{4})?' - scope: constant.numeric.value.diff - captures: - 1: punctuation.separator.sequence.diff - 2: punctuation.separator.sequence.diff - 3: punctuation.separator.sequence.diff - 4: keyword.operator.arithmetic.diff - - match: (?=$) - pop: 1 - - match: ^\b([\w-]+)\b(:) - captures: - 1: keyword.other.diff - 2: punctuation.separator.mapping.key-value.diff - push: - - meta_scope: meta.mapping.diff - - match: (?=$) - pop: 1 - - match: '{{empty_line}}' - set: git-email-body - - git-email-body: - - meta_content_scope: meta.block.git-body.diff - - match: ^(?=---\r?\n) - set: git-maybe-stat - - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message - - git-maybe-stat: - - match: ---\r?\n - scope: punctuation.definition.section.diff - set: git-stat - - match: (?=\S) - set: diff-git - - git-stat: - - match: ^ (?=([^|]+[ ]+)\|) - push: - - include: pop-before-eol - - match: (?=\S.+\|) - push: - - meta_content_scope: meta.toc-list.filename.diff entity.name.diff - - match: (?=[ ]+\|) - pop: 1 - - include: path-separators - - match: \.{3} - scope: keyword.operator.diff - - match: \| - scope: punctuation.separator.sequence.diff - - match: (Bin) (\d+) (->) (\d+) (bytes) - captures: - 1: storage.type.diff - 2: meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff - 3: keyword.operator.logical.diff - 4: meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff - 5: constant.numeric.suffix.diff - - match: \d+ - scope: meta.number.integer.decimal.diff constant.numeric.value.diff - - match: \++ - scope: markup.inserted.diff - - match: -+ - scope: markup.deleted.diff - - match: ^(?= \d+ file) - push: - - include: pop-eol - - match: \d+ - scope: meta.number.integer.decimal.diff constant.numeric.value.diff - - match: ',' - scope: punctuation.separator.sequence.diff - - match: insertions?(\()\+(\)) - scope: markup.inserted.diff - captures: - 1: punctuation.definition.diff - 2: punctuation.definition.diff - - match: deletions?(\()-(\)) - scope: markup.deleted.diff - captures: - 1: punctuation.definition.diff - 2: punctuation.definition.diff - - match: ^ (?=create mode) - push: - - meta_content_scope: markup.inserted.diff - - include: inside-create-delete-mode - - match: ^ (?=delete mode) - push: - - meta_content_scope: markup.deleted.diff - - include: inside-create-delete-mode - - match: '{{empty_line}}' - set: diff-git - - inside-create-delete-mode: - - include: pop-before-eol - - include: path-separators - - match: \b(?:100)?644\b - scope: meta.number.integer.octal.diff constant.numeric.value.diff - - match: \b(?:100)?755\b - scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.diff - diff-common: - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*$\n? scope: meta.diff.range.unified meta.range.unified.diff @@ -236,83 +59,6 @@ contexts: - match: ^\\ No newline at end of file scope: comment.line.diff - # https://git-scm.com/docs/diff-format#generate_patch_text_with_p - # TODO: multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format - diff-git: - - match: ^(-- )$\r?\n? - captures: - 1: meta.separator.diff punctuation.definition.separator.diff - set: - - meta_content_scope: comment.block.diff - - match: ^(diff) ((--)git) - captures: - 1: variable.function.diff - 2: variable.parameter.diff - 3: punctuation.definition.parameter.diff - push: - - include: pop-eol - - match: (a|b|ours|theirs)(/) - captures: - 1: constant.language.diff - 2: punctuation.separator.sequence.diff - push: - - meta_scope: entity.name.diff - - meta_content_scope: meta.toc-list.filename.diff - - match: (?=\s|$) - pop: 1 - - include: path-separators - - include: diff-git-header-extended - - match: GIT binary patch - scope: keyword.other.diff - push: - - match: ^(delta|literal) (\d+) - captures: - 1: support.function.diff - 2: meta.number.integer.decimal.diff constant.numeric.value.diff - - match: ^(H)cmV\?d00001$ - scope: constant.language.null.diff - captures: - 1: punctuation.definition.string.begin.diff - - match: ^([A-Za-z]){{base85}}{1,66}$ - scope: meta.string.diff string.other.raw.diff - captures: - 1: punctuation.definition.string.begin.diff - - match: ^(?!(delta|literal|$)) - pop: 1 - - include: diff-common - - # https://git-scm.com/docs/diff-format#generate_patch_text_with_p - diff-git-header-extended: - # old mode - # new mode - # deleted file mode - - match: ^(?=deleted file mode) - push: - - meta_content_scope: markup.deleted.diff - - include: inside-create-delete-mode - # new file mode - - match: ^(?=new file mode) - push: - - meta_content_scope: markup.inserted.diff - - include: inside-create-delete-mode - # copy from - # copy to - # rename from - # rename to - # similarity index - # dissimilarity index - # index .. - - match: ^(index) (?:(0{7,40})|({{commit_hash}}))\b(\.\.)(?:(0{7,40})|({{commit_hash}}))\b - captures: - 1: keyword.other.diff - 2: markup.deleted.diff - 3: constant.other.hash.git - 4: punctuation.separator.sequence.diff - 5: markup.deleted.diff - 6: constant.other.hash.git - push: - - include: inside-create-delete-mode - diff-generic: - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*$\n? scope: meta.diff.range.normal meta.range.normal.diff diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax new file mode 100644 index 0000000000..94cb62aadd --- /dev/null +++ b/Diff/Git Diff.sublime-syntax @@ -0,0 +1,284 @@ +%YAML 1.2 +--- +# https://www.sublimetext.com/docs/syntax.html +# https://git-scm.com/docs/git-format-patch +# https://git-scm.com/docs/diff-format +name: Git Diff +version: 2 +file_extensions: + - diff.eml + - patch.eml + - diff.mbox + - patch.mbox +first_line_match: |- + (?x)^ + (diff\ --git[ ] + |From \h{40} Mon Sep 17 00:00:00 2001 + ) + +variables: + commit_hash_full: \h{40} + commit_hash: \h{7,40} + email_first_line: (?:From {{commit_hash_full}} Mon Sep 17 00:00:00 2001) + day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) + month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) + base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' + empty_line: ^(?=\r?\n) + +scope: source.diff.git +contexts: + pop-eol: + - match: $|\r|\n + pop: 1 + + pop-before-eol: + - match: (?=$|\r|\n) + pop: 1 + + path-separators: + - match: /|\\ + scope: punctuation.separator.sequence.diff + + main: + - match: ^(?={{email_first_line}}) + push: email-first-line + - include: diffs + + # https://git-scm.com/docs/git-format-patch#_description + email-first-line: + - meta_content_scope: comment.line.diff + - match: '{{commit_hash_full}}' + scope: constant.other.hash.git + - match: \n|$ + set: email-header + + email-header: + - meta_scope: meta.block.git-header.diff + - match: |- + (?x: + ^( + From | To | Author | Committer | + Co-authored-by | + Signed-off-by | + Reviewed-by | + Acked-by | + Helped-by + ) + (:) + ) + captures: + 1: keyword + 2: punctuation.separator.mapping.key-value.diff + push: + - meta_scope: meta.mapping.diff + - include: scope:text.git.mailmap + - match: (?=$) + pop: 1 + - match: ^(Subject)(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: + - meta_scope: meta.mapping.diff + - meta_content_scope: markup.heading.diff + - match: (\[)PATCH + captures: + 1: punctuation.definition.annotation.begin.diff + push: + - meta_scope: variable.annotation.diff + - match: \] + scope: punctuation.definition.annotation.end.diff + pop: 1 + - match: \bv\d+\b + scope: meta.annotation.patch-version.diff storage.modifier.diff + - match: (\d+)(/)(\d+) + scope: meta.annotation.patch-sequence.diff + captures: + 1: meta.number.integer.decimal.diff constant.numeric.value.diff + 2: punctuation.separator.sequence.diff + 3: meta.number.integer.decimal.diff constant.numeric.value.diff + - match: (?=$) + pop: 1 + - match: ^((?:Author|Committer)?Date)(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: + - meta_scope: meta.mapping.diff + - match: '{{day3}}(,) [0-3]?\d {{month3}} \d{4} \d\d(:)\d\d(:)\d\d(?: ([+-])\d{4})?' + scope: constant.numeric.value.diff + captures: + 1: punctuation.separator.sequence.diff + 2: punctuation.separator.sequence.diff + 3: punctuation.separator.sequence.diff + 4: keyword.operator.arithmetic.diff + - match: (?=$) + pop: 1 + - match: ^\b([\w-]+)\b(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: + - meta_scope: meta.mapping.diff + - match: (?=$) + pop: 1 + - match: '{{empty_line}}' + set: email-body + + email-body: + - meta_content_scope: meta.block.git-body.diff + - match: ^(?=---\r?\n) + set: maybe-stat + - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message + + maybe-stat: + - match: ---\r?\n + scope: punctuation.definition.section.diff + set: stat + - match: (?=\S) + set: diffs + + stat: + - match: ^ (?=([^|]+[ ]+)\|) + push: + - include: pop-before-eol + - match: (?=\S.+\|) + push: + - meta_content_scope: meta.toc-list.filename.diff entity.name.diff + - match: (?=[ ]+\|) + pop: 1 + - include: path-separators + - match: \.{3} + scope: keyword.operator.diff + - match: \| + scope: punctuation.separator.sequence.diff + - match: (Bin) (\d+) (->) (\d+) (bytes) + captures: + 1: storage.type.diff + 2: meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff + 3: keyword.operator.logical.diff + 4: meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff + 5: constant.numeric.suffix.diff + - match: \d+ + scope: meta.number.integer.decimal.diff constant.numeric.value.diff + - match: \++ + scope: markup.inserted.diff + - match: -+ + scope: markup.deleted.diff + - match: ^(?= \d+ file) + push: + - include: pop-eol + - match: \d+ + scope: meta.number.integer.decimal.diff constant.numeric.value.diff + - match: ',' + scope: punctuation.separator.sequence.diff + - match: insertions?(\()\+(\)) + scope: markup.inserted.diff + captures: + 1: punctuation.definition.diff + 2: punctuation.definition.diff + - match: deletions?(\()-(\)) + scope: markup.deleted.diff + captures: + 1: punctuation.definition.diff + 2: punctuation.definition.diff + - match: ^ (?=create mode) + push: + - meta_content_scope: markup.inserted.diff + - include: inside-create-delete-mode + - match: ^ (?=delete mode) + push: + - meta_content_scope: markup.deleted.diff + - include: inside-create-delete-mode + - match: '{{empty_line}}' + set: diffs + + inside-create-delete-mode: + - include: pop-before-eol + - include: path-separators + - match: \b(?:100)?644\b + scope: meta.number.integer.octal.diff constant.numeric.value.diff + - match: \b(?:100)?755\b + scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.diff + + # https://git-scm.com/docs/diff-format#generate_patch_text_with_p + # TODO: multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format + diffs: + # Signature (usually Git version) + # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt + - match: ^(-- )$\r?\n? + captures: + 1: meta.separator.diff punctuation.definition.separator.diff + set: + - meta_content_scope: comment.block.diff + # File header + - match: ^(diff) ((--)git) + captures: + 1: variable.function.diff + 2: variable.parameter.diff + 3: punctuation.definition.parameter.diff + push: + - include: pop-eol + - match: (a|b|ours|theirs)(/) + captures: + 1: constant.language.diff + 2: punctuation.separator.sequence.diff + push: + - meta_scope: entity.name.diff + - meta_content_scope: meta.toc-list.filename.diff + - match: (?=\s|$) + pop: 1 + - include: path-separators + - include: diff-header-extended + # Binary delta, encoded in Base85 + - match: GIT binary patch + scope: keyword.other.diff + push: + - match: ^(delta|literal) (\d+) + captures: + 1: support.function.diff + 2: meta.number.integer.decimal.diff constant.numeric.value.diff + - match: ^(H)cmV\?d00001$ + scope: constant.language.null.diff + captures: + 1: punctuation.definition.string.begin.diff + - match: ^([A-Za-z]){{base85}}{1,66}$ + scope: meta.string.diff string.other.raw.diff + captures: + 1: punctuation.definition.string.begin.diff + - match: ^(?!(delta|literal|$)) + pop: 1 + # Text delta + - include: Diff.sublime-syntax#diff-common + + # https://git-scm.com/docs/diff-format#generate_patch_text_with_p + diff-header-extended: + # old mode + # new mode + # deleted file mode + - match: ^(?=deleted file mode) + push: + - meta_content_scope: markup.deleted.diff + - include: inside-create-delete-mode + # new file mode + - match: ^(?=new file mode) + push: + - meta_content_scope: markup.inserted.diff + - include: inside-create-delete-mode + # copy from + # copy to + # rename from + # rename to + # similarity index + # dissimilarity index + # index .. + - match: ^(index) (?:(0{7,40})|({{commit_hash}}))\b(\.\.)(?:(0{7,40})|({{commit_hash}}))\b + captures: + 1: keyword.other.diff + 2: markup.deleted.diff + 3: constant.other.hash.git + 4: punctuation.separator.sequence.diff + 5: markup.deleted.diff + 6: constant.other.hash.git + push: + - include: inside-create-delete-mode diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index bd5e44c7d7..ad71fa330b 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -1,4 +1,4 @@ -# SYNTAX TEST "Packages/Diff/Diff.sublime-syntax" +# SYNTAX TEST "Packages/Diff/Git Diff.sublime-syntax" From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.diff # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git From 1eca9ecdc6546cec9caaa7250fd232539ad537f3 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 020/127] [Diff] Add more Git email headers --- Diff/Git Diff.sublime-syntax | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 94cb62aadd..796f542593 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -54,26 +54,38 @@ contexts: email-header: - meta_scope: meta.block.git-header.diff + # Person headers - match: |- - (?x: - ^( - From | To | Author | Committer | - Co-authored-by | - Signed-off-by | - Reviewed-by | - Acked-by | - Helped-by + ^(?x: + ( From | To | Author | Committer + | Co-authored-by + | Signed-off-by + | Reviewed-by + | Acked-by + | Helped-by ) (:) ) captures: - 1: keyword + 1: keyword.other.diff 2: punctuation.separator.mapping.key-value.diff push: - meta_scope: meta.mapping.diff - include: scope:text.git.mailmap - match: (?=$) pop: 1 + # Commit headers + - match: ^(In-Reply-To|References)(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: + - meta_scope: meta.mapping.diff + - match: '{{commit_hash}}' + scope: constant.other.hash.git + - match: (?=$) + pop: 1 + # Subject header - match: ^(Subject)(:) captures: 1: keyword.other.diff @@ -99,6 +111,7 @@ contexts: 3: meta.number.integer.decimal.diff constant.numeric.value.diff - match: (?=$) pop: 1 + # Date headers - match: ^((?:Author|Committer)?Date)(:) captures: 1: keyword.other.diff @@ -114,6 +127,7 @@ contexts: 4: keyword.operator.arithmetic.diff - match: (?=$) pop: 1 + # Other headers - match: ^\b([\w-]+)\b(:) captures: 1: keyword.other.diff @@ -122,6 +136,7 @@ contexts: - meta_scope: meta.mapping.diff - match: (?=$) pop: 1 + # Go to Body - match: '{{empty_line}}' set: email-body From 8780272f2d1c452b9cf8d351772e969f441c6340 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 021/127] [Diff] Rename hash variables --- Diff/Git Diff.sublime-syntax | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 796f542593..58769733ba 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -17,9 +17,9 @@ first_line_match: |- ) variables: - commit_hash_full: \h{40} - commit_hash: \h{7,40} - email_first_line: (?:From {{commit_hash_full}} Mon Sep 17 00:00:00 2001) + hash40: \h{40} + hash: \h{7,40} + email_first_line: (?:From {{hash40}} Mon Sep 17 00:00:00 2001) day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' @@ -47,7 +47,7 @@ contexts: # https://git-scm.com/docs/git-format-patch#_description email-first-line: - meta_content_scope: comment.line.diff - - match: '{{commit_hash_full}}' + - match: '{{hash40}}' scope: constant.other.hash.git - match: \n|$ set: email-header @@ -81,7 +81,7 @@ contexts: 2: punctuation.separator.mapping.key-value.diff push: - meta_scope: meta.mapping.diff - - match: '{{commit_hash}}' + - match: '{{hash}}' scope: constant.other.hash.git - match: (?=$) pop: 1 @@ -287,7 +287,7 @@ contexts: # similarity index # dissimilarity index # index .. - - match: ^(index) (?:(0{7,40})|({{commit_hash}}))\b(\.\.)(?:(0{7,40})|({{commit_hash}}))\b + - match: ^(index) (?:(0{7,40})|({{hash}}))\b(\.\.)(?:(0{7,40})|({{hash}}))\b captures: 1: keyword.other.diff 2: markup.deleted.diff From 56102749e4d0c8095eb79c799e9c6a4bc3995c3c Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 022/127] [Diff] Bailout for no-stat Git diff --- Diff/Git Diff.sublime-syntax | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 58769733ba..ded5a4b0fd 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -144,6 +144,8 @@ contexts: - meta_content_scope: meta.block.git-body.diff - match: ^(?=---\r?\n) set: maybe-stat + - match: ^(?=diff --git\b) + set: diff - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message maybe-stat: From f9960f63b970f3607c72bd1a22c14a4fbd1607d3 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 023/127] [Diff] Refactor Git deltas --- Diff/Git Diff.sublime-syntax | 51 ++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index ded5a4b0fd..b27438b2de 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -39,6 +39,10 @@ contexts: - match: /|\\ scope: punctuation.separator.sequence.diff + deltas: + - include: binary-deltas + - include: text-deltas + main: - match: ^(?={{email_first_line}}) push: email-first-line @@ -219,6 +223,7 @@ contexts: scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.diff # https://git-scm.com/docs/diff-format#generate_patch_text_with_p + # TODO: Full meta block for each file header. # TODO: multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format diffs: # Signature (usually Git version) @@ -247,26 +252,7 @@ contexts: pop: 1 - include: path-separators - include: diff-header-extended - # Binary delta, encoded in Base85 - - match: GIT binary patch - scope: keyword.other.diff - push: - - match: ^(delta|literal) (\d+) - captures: - 1: support.function.diff - 2: meta.number.integer.decimal.diff constant.numeric.value.diff - - match: ^(H)cmV\?d00001$ - scope: constant.language.null.diff - captures: - 1: punctuation.definition.string.begin.diff - - match: ^([A-Za-z]){{base85}}{1,66}$ - scope: meta.string.diff string.other.raw.diff - captures: - 1: punctuation.definition.string.begin.diff - - match: ^(?!(delta|literal|$)) - pop: 1 - # Text delta - - include: Diff.sublime-syntax#diff-common + - include: deltas # https://git-scm.com/docs/diff-format#generate_patch_text_with_p diff-header-extended: @@ -299,3 +285,28 @@ contexts: 6: constant.other.hash.git push: - include: inside-create-delete-mode + + # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c + binary-deltas: + - match: ^GIT binary patch + scope: keyword.other.diff + push: + - match: ^(delta|literal) (\d+) + captures: + 1: support.function.diff + 2: meta.number.integer.decimal.diff constant.numeric.value.diff + # Empty file + - match: ^(H)cmV\?d00001$ + scope: constant.language.null.diff + captures: + 1: punctuation.definition.string.begin.diff + - match: ^([A-Za-z]){{base85}}{1,66}$ + scope: meta.string.diff string.other.raw.diff + captures: + 1: punctuation.definition.string.begin.diff + - match: ^(?!(delta|literal|$)) + pop: 1 + + # TODO: Multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format + text-deltas: + - include: Diff.sublime-syntax#diff-common From 50ed8bc915a96f25dc2324855b518b3789568d6e Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 024/127] [Diff] Git diff signature. More file headers. --- Diff/Git Diff.sublime-syntax | 55 ++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index b27438b2de..d16915b525 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -206,17 +206,19 @@ contexts: - match: ^ (?=create mode) push: - meta_content_scope: markup.inserted.diff - - include: inside-create-delete-mode + - include: pop-before-eol + - include: path-separators + - include: file-modes - match: ^ (?=delete mode) push: - meta_content_scope: markup.deleted.diff - - include: inside-create-delete-mode + - include: pop-before-eol + - include: path-separators + - include: file-modes - match: '{{empty_line}}' set: diffs - inside-create-delete-mode: - - include: pop-before-eol - - include: path-separators + file-modes: - match: \b(?:100)?644\b scope: meta.number.integer.octal.diff constant.numeric.value.diff - match: \b(?:100)?755\b @@ -224,15 +226,8 @@ contexts: # https://git-scm.com/docs/diff-format#generate_patch_text_with_p # TODO: Full meta block for each file header. - # TODO: multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format diffs: - # Signature (usually Git version) - # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt - - match: ^(-- )$\r?\n? - captures: - 1: meta.separator.diff punctuation.definition.separator.diff - set: - - meta_content_scope: comment.block.diff + - include: signature # File header - match: ^(diff) ((--)git) captures: @@ -240,14 +235,14 @@ contexts: 2: variable.parameter.diff 3: punctuation.definition.parameter.diff push: + - meta_scope: meta.toc-list.git - include: pop-eol - - match: (a|b|ours|theirs)(/) + - match: \b(a|b|ours|theirs)(/) captures: 1: constant.language.diff 2: punctuation.separator.sequence.diff push: - meta_scope: entity.name.diff - - meta_content_scope: meta.toc-list.filename.diff - match: (?=\s|$) pop: 1 - include: path-separators @@ -262,18 +257,32 @@ contexts: - match: ^(?=deleted file mode) push: - meta_content_scope: markup.deleted.diff - - include: inside-create-delete-mode + - include: pop-before-eol + - include: file-modes # new file mode - match: ^(?=new file mode) push: - meta_content_scope: markup.inserted.diff - - include: inside-create-delete-mode + - include: pop-before-eol + - include: file-modes # copy from # copy to # rename from # rename to + - match: ^(?:copy|rename) (from|to) + push: + - include: pop-before-eol + - include: path-separators # similarity index # dissimilarity index + - match: ^(?:dis)?similarity index + push: + - include: pop-before-eol + - match: (100|[1-9]?\d)(%) + scope: meta.number.integer.decimal.git + captures: + 1: constant.numeric.value.git + 2: constant.numeric.suffix.git # index .. - match: ^(index) (?:(0{7,40})|({{hash}}))\b(\.\.)(?:(0{7,40})|({{hash}}))\b captures: @@ -284,7 +293,8 @@ contexts: 5: markup.deleted.diff 6: constant.other.hash.git push: - - include: inside-create-delete-mode + - include: pop-before-eol + - include: file-modes # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c binary-deltas: @@ -310,3 +320,12 @@ contexts: # TODO: Multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format text-deltas: - include: Diff.sublime-syntax#diff-common + + # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt + signature: + # This is the Git version unless otherwise configured + - match: ^(-- )$\r?\n? + captures: + 1: meta.separator.diff punctuation.definition.separator.diff + set: + - meta_content_scope: comment.block.diff From 11292ec0024a28aeb2f85f1eaae9b1e1a337d8a2 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 025/127] [Diff] Modify file header first line detection --- Diff/Git Diff.sublime-syntax | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index d16915b525..63fd71efd6 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -148,7 +148,8 @@ contexts: - meta_content_scope: meta.block.git-body.diff - match: ^(?=---\r?\n) set: maybe-stat - - match: ^(?=diff --git\b) + # https://git-scm.com/docs/git-am#_discussion + - match: '^(?=Index: |diff -)' set: diff - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message From 8902243fb97215e0fc4895e0f3f579b0274aff70 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 026/127] [Diff] Refactor pre-EOL pops --- Diff/Git Diff.sublime-syntax | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 63fd71efd6..37350703d2 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -76,8 +76,7 @@ contexts: push: - meta_scope: meta.mapping.diff - include: scope:text.git.mailmap - - match: (?=$) - pop: 1 + - include: pop-before-eol # Commit headers - match: ^(In-Reply-To|References)(:) captures: @@ -87,8 +86,7 @@ contexts: - meta_scope: meta.mapping.diff - match: '{{hash}}' scope: constant.other.hash.git - - match: (?=$) - pop: 1 + - include: pop-before-eol # Subject header - match: ^(Subject)(:) captures: @@ -113,8 +111,7 @@ contexts: 1: meta.number.integer.decimal.diff constant.numeric.value.diff 2: punctuation.separator.sequence.diff 3: meta.number.integer.decimal.diff constant.numeric.value.diff - - match: (?=$) - pop: 1 + - include: pop-before-eol # Date headers - match: ^((?:Author|Committer)?Date)(:) captures: @@ -129,8 +126,7 @@ contexts: 2: punctuation.separator.sequence.diff 3: punctuation.separator.sequence.diff 4: keyword.operator.arithmetic.diff - - match: (?=$) - pop: 1 + - include: pop-before-eol # Other headers - match: ^\b([\w-]+)\b(:) captures: @@ -138,8 +134,7 @@ contexts: 2: punctuation.separator.mapping.key-value.diff push: - meta_scope: meta.mapping.diff - - match: (?=$) - pop: 1 + - include: pop-before-eol # Go to Body - match: '{{empty_line}}' set: email-body From 72d82159a936e28f0eb617b8e3fd519980e91126 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 027/127] [Diff] Block contexts for diff header and content --- Diff/Git Diff.sublime-syntax | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 37350703d2..2ed663bf43 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -221,28 +221,38 @@ contexts: scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.diff # https://git-scm.com/docs/diff-format#generate_patch_text_with_p - # TODO: Full meta block for each file header. diffs: - include: signature - # File header - match: ^(diff) ((--)git) captures: 1: variable.function.diff 2: variable.parameter.diff 3: punctuation.definition.parameter.diff + push: [diff-header, file-header-continue] + + file-header-continue: + - meta_scope: meta.toc-list.git + - include: pop-eol + - match: \b(a|b|ours|theirs)(/) + captures: + 1: constant.language.diff + 2: punctuation.separator.sequence.diff push: - - meta_scope: meta.toc-list.git - - include: pop-eol - - match: \b(a|b|ours|theirs)(/) - captures: - 1: constant.language.diff - 2: punctuation.separator.sequence.diff - push: - - meta_scope: entity.name.diff - - match: (?=\s|$) - pop: 1 - - include: path-separators + - meta_scope: entity.name.diff + - match: (?=\s|$) + pop: 1 + - include: path-separators + + diff-header: + - meta_scope: meta.block.header.diff + - match: ^(?=@|GIT binary) + set: diff-content - include: diff-header-extended + + diff-content: + - meta_content_scope: meta.block.delta.diff + - match: ^(?=diff --git\b) + pop: 1 - include: deltas # https://git-scm.com/docs/diff-format#generate_patch_text_with_p From 938ef144014bc27c844d439b6a486c16b1e9b520 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 028/127] fixup executable file mode scope --- Diff/Git Diff.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 2ed663bf43..adc7c4f003 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -218,7 +218,7 @@ contexts: - match: \b(?:100)?644\b scope: meta.number.integer.octal.diff constant.numeric.value.diff - match: \b(?:100)?755\b - scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.diff + scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff # https://git-scm.com/docs/diff-format#generate_patch_text_with_p diffs: From 660fb2e50aa54746e1b6bbc072c5198c88a96c85 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 029/127] [Diff] Drop unnecessary context --- Diff/Git Diff.sublime-syntax | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index adc7c4f003..e76624ffb7 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -247,16 +247,6 @@ contexts: - meta_scope: meta.block.header.diff - match: ^(?=@|GIT binary) set: diff-content - - include: diff-header-extended - - diff-content: - - meta_content_scope: meta.block.delta.diff - - match: ^(?=diff --git\b) - pop: 1 - - include: deltas - - # https://git-scm.com/docs/diff-format#generate_patch_text_with_p - diff-header-extended: # old mode # new mode # deleted file mode @@ -302,6 +292,12 @@ contexts: - include: pop-before-eol - include: file-modes + diff-content: + - meta_content_scope: meta.block.delta.diff + - match: ^(?=diff --git\b) + pop: 1 + - include: deltas + # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c binary-deltas: - match: ^GIT binary patch From 32326aa592904830d84051bebea49a9d8209f86d Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 030/127] [Diff] WIP skippable stat --- Diff/Git Diff.sublime-syntax | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index e76624ffb7..d178d66c5c 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -141,21 +141,18 @@ contexts: email-body: - meta_content_scope: meta.block.git-body.diff - - match: ^(?=---\r?\n) - set: maybe-stat + - match: ^(---)\r?\n + captures: + 1: punctuation.definition.section.diff + set: [diffs, stat] # https://git-scm.com/docs/git-am#_discussion - match: '^(?=Index: |diff -)' - set: diff - - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message - - maybe-stat: - - match: ---\r?\n - scope: punctuation.definition.section.diff - set: stat - - match: (?=\S) set: diffs + - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message stat: + - match: ^(?=\S) + pop: 1 - match: ^ (?=([^|]+[ ]+)\|) push: - include: pop-before-eol From aa9a634bab176a8d5f9abc365a722a11041fd5aa Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 031/127] fixup Add context for pre-file header pop --- Diff/Git Diff.sublime-syntax | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index d178d66c5c..b9a26b0add 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -35,6 +35,10 @@ contexts: - match: (?=$|\r|\n) pop: 1 + pop-before-diff-header: + - match: ^(?=diff --git\b) + pop: 1 + path-separators: - match: /|\\ scope: punctuation.separator.sequence.diff @@ -151,8 +155,7 @@ contexts: - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message stat: - - match: ^(?=\S) - pop: 1 + - include: pop-before-diff-header - match: ^ (?=([^|]+[ ]+)\|) push: - include: pop-before-eol @@ -291,8 +294,7 @@ contexts: diff-content: - meta_content_scope: meta.block.delta.diff - - match: ^(?=diff --git\b) - pop: 1 + - include: pop-before-diff-header - include: deltas # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c From 32a8cd6d064eb06f93a04e3905f161728eb09bbb Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 032/127] fixup Binary patch content --- Diff/Git Diff.sublime-syntax | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index b9a26b0add..ca62183b02 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -245,6 +245,7 @@ contexts: diff-header: - meta_scope: meta.block.header.diff + # Detect & switch context to changed content - match: ^(?=@|GIT binary) set: diff-content # old mode @@ -315,8 +316,8 @@ contexts: scope: meta.string.diff string.other.raw.diff captures: 1: punctuation.definition.string.begin.diff - - match: ^(?!(delta|literal|$)) - pop: 1 + - match: ^(?!delta|literal|$) + pop: 2 # TODO: Multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format text-deltas: From 8bfa5391b693b1eaebbce4b060dae5a83adc4702 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:04 -0500 Subject: [PATCH 033/127] [Diff] Expand/comment Git index file header --- Diff/Git Diff.sublime-syntax | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index ca62183b02..166dcfb804 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -281,7 +281,19 @@ contexts: 1: constant.numeric.value.git 2: constant.numeric.suffix.git # index .. - - match: ^(index) (?:(0{7,40})|({{hash}}))\b(\.\.)(?:(0{7,40})|({{hash}}))\b + - match: |- + ^(?x: + (index)[ ] + (?: + (0{7,40}) # Empty hash + | ({{hash}}) # File content hash + )\b + (\.\.) # Double-dot separator + (?: + (0{7,40}) # Empty hash + | ({{hash}}) # File content hash + )\b + ) captures: 1: keyword.other.diff 2: markup.deleted.diff From ad5768283417ec1c3f6160e5fb075b6cd68b80c1 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 034/127] [Diff] Split traditional diff into more contexts --- Diff/Diff.sublime-syntax | 138 ++++++++++++++++++++--------------- Diff/Git Diff.sublime-syntax | 5 +- 2 files changed, 81 insertions(+), 62 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 5f6faffd35..9f335c28fc 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -18,94 +18,112 @@ first_line_match: |- variables: git_first_line: (?:From \h{40} Mon Sep 17 00:00:00 2001) + eol: $\r?\n? scope: source.diff contexts: + pop-eol: + - match: '{{eol}}' + pop: 1 + main: - match: ^(?={{git_first_line}}) push: Git Diff.sublime-syntax#email-first-line - - include: diff-generic + - include: line-ranges + - include: headers + - include: deltas - diff-common: - - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*$\n? - scope: meta.diff.range.unified meta.range.unified.diff - captures: - 1: punctuation.definition.range.diff - 2: meta.toc-list.line-number.diff - 3: punctuation.definition.range.diff - 4: entity.name.section.diff - - match: ^-{3}$\n? + headers: + - match: ^-{3}{{eol}} scope: meta.separator.diff punctuation.definition.separator.diff - - match: ^(-{3}) (?:(/dev/null)|.+)$\n? + - match: ^(-{3}) (?:(/dev/null)|.+){{eol}} scope: meta.diff.header.from-file meta.header.from-file.diff captures: 1: punctuation.definition.from-file.diff 2: constant.language.null.diff - - match: ^(\+{3}) (?:(/dev/null)|.+)$\n? + - match: ^(\+{3}) (?:(/dev/null)|.+){{eol}} scope: meta.diff.header.to-file meta.header.to-file.diff captures: 1: punctuation.definition.to-file.diff 2: constant.language.null.diff - - match: ^(\+).*?(\s*?)$\n? - scope: markup.inserted.diff + - match: ^(\*{15}|={67}){{eol}} + scope: meta.separator.diff captures: - 1: punctuation.definition.inserted.diff - 2: meta.whitespace.trailing.diff - - match: ^(-).*?(\s*?)$\n? - scope: markup.deleted.diff + 1: punctuation.definition.separator.diff + - match: ^(?:(\*{3}) .+){{eol}}|^(={4}) .+(?= - ) + scope: meta.diff.header.from-file meta.header.from-file.diff captures: - 1: punctuation.definition.deleted.diff - 2: meta.whitespace.trailing.diff - - match: ^\\ No newline at end of file - scope: comment.line.diff + 1: punctuation.definition.from-file.diff + 2: punctuation.definition.from-file.diff + push: + - match: ' (-) .* (={4}){{eol}}' + scope: meta.diff.header.to-file meta.header.to-file.diff + captures: + 1: punctuation.definition.to-file.diff + 2: punctuation.definition.to-file.diff + pop: 1 + - match: '' + pop: 1 + - match: ^Index(:) (.+){{eol}} + scope: meta.diff.index meta.index.diff + captures: + 1: punctuation.separator.key-value.diff + 2: meta.toc-list.file-name.diff - diff-generic: - - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*$\n? + line-ranges: + - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*{{eol}} + scope: meta.diff.range.unified meta.range.unified.diff + captures: + 1: punctuation.definition.range.diff + 2: meta.toc-list.line-number.diff + 3: punctuation.definition.range.diff + 4: entity.name.section.diff + - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*{{eol}} scope: meta.diff.range.normal meta.range.normal.diff captures: 1: punctuation.separator.sequence.diff 2: markup.inserted.diff 3: markup.deleted.diff 4: markup.changed.diff - - match: ^(?:(-{3}) .+ (-{4})|(\*{3}) .+ (\*{4}))$\n? + - match: ^(?:(-{3}) .+ (-{4})|(\*{3}) .+ (\*{4})){{eol}} scope: meta.diff.range.context meta.range.context.diff captures: 1: punctuation.definition.range.diff 2: punctuation.definition.range.diff 3: punctuation.definition.range.diff 4: punctuation.definition.range.diff - - match: ^(\*{15}|={67})$\n? - scope: meta.separator.diff - captures: - 1: punctuation.definition.separator.diff - - match: ^(!).*?(\s*?)$\n? - scope: markup.changed.diff - captures: - 1: punctuation.definition.changed.diff - 2: meta.whitespace.trailing.diff - - match: ^(>).*?(\s*?)$\n? - scope: markup.inserted.diff - captures: - 1: punctuation.definition.inserted.diff - 2: meta.whitespace.trailing.diff - - match: ^(<).*?(\s*?)$\n? - scope: markup.deleted.diff - captures: - 1: punctuation.definition.deleted.diff - 2: meta.whitespace.trailing.diff - - match: ^(?:(\*{3}) .+)$\n?|^(={4}) .+(?= - ) - scope: meta.diff.header.from-file meta.header.from-file.diff - captures: - 1: punctuation.definition.from-file.diff - 2: punctuation.definition.from-file.diff - - match: ' (-) .* (={4})$\n?' - scope: meta.diff.header.to-file meta.header.to-file.diff - captures: - 1: punctuation.definition.to-file.diff - 2: punctuation.definition.to-file.diff - - match: ^Index(:) (.+)$\n? - scope: meta.diff.index meta.index.diff - captures: - 1: punctuation.separator.key-value.diff - 2: meta.toc-list.file-name.diff - - include: diff-common + + deltas: + - match: ^[+>] + scope: punctuation.definition.inserted.diff + push: line-inserted + - match: ^[-<] + scope: punctuation.definition.deleted.diff + push: line-deleted + - match: ^[!|] + scope: punctuation.definition.changed.diff + push: line-changed + - match: ^[()\\/] + scope: punctuation.definition.comment.begin.diff + push: line-ignored + + line-deleted: + - meta_scope: markup.deleted.diff + - include: pop-eol + - include: trailing-whitespace + line-inserted: + - meta_scope: markup.inserted.diff + - include: pop-eol + - include: trailing-whitespace + line-changed: + - meta_scope: markup.changed.diff + - include: pop-eol + - include: trailing-whitespace + line-ignored: + - meta_scope: comment.line.diff + - include: pop-eol + - include: trailing-whitespace + + trailing-whitespace: + - match: '[ \t]*(?=$)' + scope: meta.whitespace.trailing.diff diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 166dcfb804..263e8e0fb7 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -333,12 +333,13 @@ contexts: # TODO: Multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format text-deltas: - - include: Diff.sublime-syntax#diff-common + - include: Diff.sublime-syntax#line-ranges + - include: Diff.sublime-syntax#deltas # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt signature: # This is the Git version unless otherwise configured - - match: ^(-- )$\r?\n? + - match: ^(-- ){{eol}} captures: 1: meta.separator.diff punctuation.definition.separator.diff set: From 3002e53e23f7707904fa55fa41e9193c33aed555 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 035/127] [Diff] Escape chars in Git filenames --- Diff/Git Diff.sublime-syntax | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 263e8e0fb7..a514df2c2e 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -233,12 +233,15 @@ contexts: file-header-continue: - meta_scope: meta.toc-list.git - include: pop-eol + # TODO: Quoted file names https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath - match: \b(a|b|ours|theirs)(/) captures: 1: constant.language.diff 2: punctuation.separator.sequence.diff push: - meta_scope: entity.name.diff + - match: \\. + scope: constant.character.escape.git - match: (?=\s|$) pop: 1 - include: path-separators From fc7b19290ee232457f7dbafa0ff8fe82aa60e4e9 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 036/127] [Diff] Link GNU diff documentation --- Diff/Diff.sublime-syntax | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 9f335c28fc..84fc262e94 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -1,6 +1,7 @@ %YAML 1.2 --- # https://www.sublimetext.com/docs/syntax.html +# https://www.gnu.org/software/diffutils/manual/html_node/index.html name: Diff version: 2 file_extensions: @@ -34,8 +35,11 @@ contexts: - include: deltas headers: + # https://www.gnu.org/software/diffutils/manual/html_node/Hunks.html - match: ^-{3}{{eol}} scope: meta.separator.diff punctuation.definition.separator.diff + + # https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html - match: ^(-{3}) (?:(/dev/null)|.+){{eol}} scope: meta.diff.header.from-file meta.header.from-file.diff captures: @@ -46,15 +50,19 @@ contexts: captures: 1: punctuation.definition.to-file.diff 2: constant.language.null.diff + - match: ^(\*{15}|={67}){{eol}} scope: meta.separator.diff captures: 1: punctuation.definition.separator.diff - - match: ^(?:(\*{3}) .+){{eol}}|^(={4}) .+(?= - ) + - match: ^(\*{3}) .+{{eol}} + scope: meta.diff.header.from-file meta.header.from-file.diff + captures: + 1: punctuation.definition.from-file.diff + - match: ^(={4}) .+(?= - ) scope: meta.diff.header.from-file meta.header.from-file.diff captures: 1: punctuation.definition.from-file.diff - 2: punctuation.definition.from-file.diff push: - match: ' (-) .* (={4}){{eol}}' scope: meta.diff.header.to-file meta.header.to-file.diff @@ -71,6 +79,7 @@ contexts: 2: meta.toc-list.file-name.diff line-ranges: + # https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*{{eol}} scope: meta.diff.range.unified meta.range.unified.diff captures: @@ -78,6 +87,7 @@ contexts: 2: meta.toc-list.line-number.diff 3: punctuation.definition.range.diff 4: entity.name.section.diff + # https://www.gnu.org/software/diffutils/manual/html_node/Hunks.html - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*{{eol}} scope: meta.diff.range.normal meta.range.normal.diff captures: @@ -85,15 +95,24 @@ contexts: 2: markup.inserted.diff 3: markup.deleted.diff 4: markup.changed.diff - - match: ^(?:(-{3}) .+ (-{4})|(\*{3}) .+ (\*{4})){{eol}} + # https://www.gnu.org/software/diffutils/manual/html_node/Example-Context.html + - match: |- + ^(?x: + ( -{3})[ ].+[ ]( -{4}) # From range + | (\*{3})[ ].+[ ](\*{4}) # To range + ){{eol}} scope: meta.diff.range.context meta.range.context.diff captures: 1: punctuation.definition.range.diff 2: punctuation.definition.range.diff 3: punctuation.definition.range.diff 4: punctuation.definition.range.diff + # TODO: diff3 https://www.gnu.org/software/diffutils/manual/html_node/Example-diff3-Normal.html deltas: + # https://www.gnu.org/software/diffutils/manual/html_node/Example-Context.html + # https://www.gnu.org/software/diffutils/manual/html_node/Example-Unified.html + # https://www.gnu.org/software/diffutils/manual/html_node/Example-Normal.html - match: ^[+>] scope: punctuation.definition.inserted.diff push: line-inserted @@ -103,7 +122,8 @@ contexts: - match: ^[!|] scope: punctuation.definition.changed.diff push: line-changed - - match: ^[()\\/] + # https://www.gnu.org/software/diffutils/manual/html_node/Incomplete-Lines.html + - match: ^[\\/()] scope: punctuation.definition.comment.begin.diff push: line-ignored From c2c11d5c7cfbf1a00530b4ec6d47eebd8c3fd6a6 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 037/127] [Diff] Try circular extends --- Diff/Git Diff.sublime-syntax | 1 + 1 file changed, 1 insertion(+) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index a514df2c2e..c83ecf0947 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -5,6 +5,7 @@ # https://git-scm.com/docs/diff-format name: Git Diff version: 2 +extends: Diff.sublime-syntax file_extensions: - diff.eml - patch.eml From 029e22dd18036c0b732265ef30092ba12d994cac Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 038/127] [Diff] Extended syntax consolidation --- Diff/Diff.sublime-syntax | 4 ++++ Diff/Git Diff.sublime-syntax | 22 +++------------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 84fc262e94..461aa0923b 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -27,6 +27,10 @@ contexts: - match: '{{eol}}' pop: 1 + pop-before-eol: + - match: (?={{eol}}) + pop: 1 + main: - match: ^(?={{git_first_line}}) push: Git Diff.sublime-syntax#email-first-line diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index c83ecf0947..6fad1a720a 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -20,7 +20,6 @@ first_line_match: |- variables: hash40: \h{40} hash: \h{7,40} - email_first_line: (?:From {{hash40}} Mon Sep 17 00:00:00 2001) day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' @@ -28,14 +27,6 @@ variables: scope: source.diff.git contexts: - pop-eol: - - match: $|\r|\n - pop: 1 - - pop-before-eol: - - match: (?=$|\r|\n) - pop: 1 - pop-before-diff-header: - match: ^(?=diff --git\b) pop: 1 @@ -44,12 +35,8 @@ contexts: - match: /|\\ scope: punctuation.separator.sequence.diff - deltas: - - include: binary-deltas - - include: text-deltas - main: - - match: ^(?={{email_first_line}}) + - match: ^(?={{git_first_line}}) push: email-first-line - include: diffs @@ -312,6 +299,8 @@ contexts: diff-content: - meta_content_scope: meta.block.delta.diff - include: pop-before-diff-header + - include: binary-deltas + # TODO: Multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format - include: deltas # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c @@ -335,11 +324,6 @@ contexts: - match: ^(?!delta|literal|$) pop: 2 - # TODO: Multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format - text-deltas: - - include: Diff.sublime-syntax#line-ranges - - include: Diff.sublime-syntax#deltas - # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt signature: # This is the Git version unless otherwise configured From 58ec9a141091f2676378dcf7089d6e6c9d0af4c3 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 039/127] [Diff] Split unified headers off to new contexts --- Diff/Diff.sublime-syntax | 44 ++++++++++++++++++++---------------- Diff/Git Diff.sublime-syntax | 2 ++ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 461aa0923b..7130da69ea 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -43,17 +43,7 @@ contexts: - match: ^-{3}{{eol}} scope: meta.separator.diff punctuation.definition.separator.diff - # https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html - - match: ^(-{3}) (?:(/dev/null)|.+){{eol}} - scope: meta.diff.header.from-file meta.header.from-file.diff - captures: - 1: punctuation.definition.from-file.diff - 2: constant.language.null.diff - - match: ^(\+{3}) (?:(/dev/null)|.+){{eol}} - scope: meta.diff.header.to-file meta.header.to-file.diff - captures: - 1: punctuation.definition.to-file.diff - 2: constant.language.null.diff + - include: headers-unified - match: ^(\*{15}|={67}){{eol}} scope: meta.separator.diff @@ -82,15 +72,21 @@ contexts: 1: punctuation.separator.key-value.diff 2: meta.toc-list.file-name.diff - line-ranges: - # https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html - - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*{{eol}} - scope: meta.diff.range.unified meta.range.unified.diff + # https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html + headers-unified: + - match: ^(-{3}) (?:(/dev/null)|.+){{eol}} + scope: meta.diff.header.from-file meta.header.from-file.diff captures: - 1: punctuation.definition.range.diff - 2: meta.toc-list.line-number.diff - 3: punctuation.definition.range.diff - 4: entity.name.section.diff + 1: punctuation.definition.from-file.diff + 2: constant.language.null.diff + - match: ^(\+{3}) (?:(/dev/null)|.+){{eol}} + scope: meta.diff.header.to-file meta.header.to-file.diff + captures: + 1: punctuation.definition.to-file.diff + 2: constant.language.null.diff + + line-ranges: + - include: line-ranges-unified # https://www.gnu.org/software/diffutils/manual/html_node/Hunks.html - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*{{eol}} scope: meta.diff.range.normal meta.range.normal.diff @@ -113,6 +109,16 @@ contexts: 4: punctuation.definition.range.diff # TODO: diff3 https://www.gnu.org/software/diffutils/manual/html_node/Example-diff3-Normal.html + # https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html + line-ranges-unified: + - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*{{eol}} + scope: meta.diff.range.unified meta.range.unified.diff + captures: + 1: punctuation.definition.range.diff + 2: meta.toc-list.line-number.diff + 3: punctuation.definition.range.diff + 4: entity.name.section.diff + deltas: # https://www.gnu.org/software/diffutils/manual/html_node/Example-Context.html # https://www.gnu.org/software/diffutils/manual/html_node/Example-Unified.html diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 6fad1a720a..c1efbde6cd 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -239,6 +239,7 @@ contexts: # Detect & switch context to changed content - match: ^(?=@|GIT binary) set: diff-content + - include: headers-unified # old mode # new mode # deleted file mode @@ -301,6 +302,7 @@ contexts: - include: pop-before-diff-header - include: binary-deltas # TODO: Multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format + - include: line-ranges-unified - include: deltas # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c From 28ccfdf89dfda0d1e2c8fb5a69651fb6af99e3a2 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 040/127] [Diff] Add optional date modified in file header --- Diff/Diff.sublime-syntax | 55 +++++++++++++++++++++++----- Diff/Git Diff.sublime-syntax | 4 --- Diff/tests/syntax_test_diff.diff | 62 ++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 12 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 7130da69ea..1475364216 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -49,10 +49,15 @@ contexts: scope: meta.separator.diff captures: 1: punctuation.definition.separator.diff - - match: ^(\*{3}) .+{{eol}} - scope: meta.diff.header.from-file meta.header.from-file.diff + - match: ^(\*{3})[ ](?!$) captures: 1: punctuation.definition.from-file.diff + push: + - meta_scope: meta.diff.header.from-file meta.header.from-file.diff + - include: pop-eol + - include: dev-null + - include: path-separators + - include: date - match: ^(={4}) .+(?= - ) scope: meta.diff.header.from-file meta.header.from-file.diff captures: @@ -74,16 +79,24 @@ contexts: # https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html headers-unified: - - match: ^(-{3}) (?:(/dev/null)|.+){{eol}} - scope: meta.diff.header.from-file meta.header.from-file.diff + - match: ^(-{3})[ ](?!$) captures: 1: punctuation.definition.from-file.diff - 2: constant.language.null.diff - - match: ^(\+{3}) (?:(/dev/null)|.+){{eol}} - scope: meta.diff.header.to-file meta.header.to-file.diff + push: + - meta_scope: meta.diff.header.from-file meta.header.from-file.diff + - include: pop-eol + - include: dev-null + - include: path-separators + - include: date + - match: ^(\+{3})[ ](?!$) captures: 1: punctuation.definition.to-file.diff - 2: constant.language.null.diff + push: + - meta_scope: meta.diff.header.to-file meta.header.to-file.diff + - include: pop-eol + - include: dev-null + - include: path-separators + - include: date line-ranges: - include: line-ranges-unified @@ -157,3 +170,29 @@ contexts: trailing-whitespace: - match: '[ \t]*(?=$)' scope: meta.whitespace.trailing.diff + + dev-null: + - match: /dev/null\b + scope: constant.language.null.diff + + path-separators: + - match: /|\\ + scope: punctuation.separator.sequence.diff + + date: + # 2002-02-21 23:30:50.442260588 -0800 + - match: \b(\d{4})(-)(\d\d)(-)(\d\d) (\d?\d)(:)(\d\d)(:)(\d\d(?:(\.)\d+)?)(?:[ ]([+-]\d{4}))? + scope: meta.date.diff + captures: + 1: meta.number.integer.decimal.diff constant.numeric.value.diff + 2: punctuation.separator.sequence.diff + 3: meta.number.integer.decimal.diff constant.numeric.value.diff + 4: punctuation.separator.sequence.diff + 5: meta.number.integer.decimal.diff constant.numeric.value.diff + 6: meta.number.integer.decimal.diff constant.numeric.value.diff + 7: punctuation.separator.sequence.diff + 8: meta.number.integer.decimal.diff constant.numeric.value.diff + 9: punctuation.separator.sequence.diff + 10: meta.number.float.decimal.diff constant.numeric.value.diff + 11: punctuation.separator.decimal.diff + 12: storage.modifier.diff diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index c1efbde6cd..15164184dd 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -31,10 +31,6 @@ contexts: - match: ^(?=diff --git\b) pop: 1 - path-separators: - - match: /|\\ - scope: punctuation.separator.sequence.diff - main: - match: ^(?={{git_first_line}}) push: email-first-line diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 2def567589..3c96520b41 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -106,3 +106,65 @@ Index: value #^^^^^^^^^^^ meta.diff.index meta.index.diff # ^ punctuation.separator.key-value.diff # ^^^^^ meta.toc-list.file-name.diff + +\ No newline at end of file +#^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line +# <- punctuation.definition.comment + + +Unified Format https://www.gnu.org/software/diffutils/manual/html_node/Example-Unified.html +--- lao 2002-02-21 23:30:39.942229878 -0800 +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.from-file +#^^ punctuation.definition.from-file +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.date.diff ++++ tzu 2002-02-21 23:30:50.442260588 -0800 +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.to-file +#^^ punctuation.definition.to-file +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.date.diff +@@ -1,7 +1,6 @@ +-The Way that can be told of is not the eternal Way; +-The name that can be named is not the eternal name. + The Nameless is the origin of Heaven and Earth; +-The Named is the mother of all things. ++The named is the mother of all things. ++ + Therefore let there always be non-being, + so we may see their subtlety, + And let there always be being, +@@ -9,3 +8,6 @@ + The two are the same, + But after they are produced, + they have different names. ++They both may be called deep and profound. ++Deeper and more profound, ++The door of all subtleties! + + +Context Format https://www.gnu.org/software/diffutils/manual/html_node/Example-Context.html +*** lao 2002-02-21 23:30:39.942229878 -0800 +--- tzu 2002-02-21 23:30:50.442260588 -0800 +*************** +*** 1,7 **** +- The Way that can be told of is not the eternal Way; +- The name that can be named is not the eternal name. + The Nameless is the origin of Heaven and Earth; +! The Named is the mother of all things. + Therefore let there always be non-being, + so we may see their subtlety, + And let there always be being, +--- 1,6 ---- + The Nameless is the origin of Heaven and Earth; +! The named is the mother of all things. +! + Therefore let there always be non-being, + so we may see their subtlety, + And let there always be being, +*************** +*** 9,11 **** +--- 8,13 ---- + The two are the same, + But after they are produced, + they have different names. ++ They both may be called deep and profound. ++ Deeper and more profound, ++ The door of all subtleties! From 208a40ac31e23a83a932618f40a8439271a17f76 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 041/127] [Diff] Simplify date scopes --- Diff/Diff.sublime-syntax | 28 ++++++++++++++++------------ Diff/tests/syntax_test_diff.diff | 4 ++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 1475364216..f95c984701 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -180,19 +180,23 @@ contexts: scope: punctuation.separator.sequence.diff date: + # 1970-01-01 00:00:00 +0000 + - match: \b1970(-)01(-)01 0?0(:)00(:)00(?:(\.)0+)?(?:[ ]([+-]?0000|UTC))? + scope: meta.date.diff constant.language.null.diff + captures: + 1: punctuation.separator.sequence.diff + 2: punctuation.separator.sequence.diff + 3: punctuation.separator.sequence.diff + 4: punctuation.separator.sequence.diff + 5: punctuation.separator.decimal.diff + 6: storage.modifier.diff # 2002-02-21 23:30:50.442260588 -0800 - - match: \b(\d{4})(-)(\d\d)(-)(\d\d) (\d?\d)(:)(\d\d)(:)(\d\d(?:(\.)\d+)?)(?:[ ]([+-]\d{4}))? - scope: meta.date.diff + - match: \b\d{4}(-)\d\d(-)\d\d \d?\d(:)\d\d(:)\d\d(?:(\.)\d+)?(?:[ ]([+-]?\d{4}))? + scope: meta.date.diff meta.number.integer.decimal.diff constant.numeric.value.diff captures: - 1: meta.number.integer.decimal.diff constant.numeric.value.diff + 1: punctuation.separator.sequence.diff 2: punctuation.separator.sequence.diff - 3: meta.number.integer.decimal.diff constant.numeric.value.diff + 3: punctuation.separator.sequence.diff 4: punctuation.separator.sequence.diff - 5: meta.number.integer.decimal.diff constant.numeric.value.diff - 6: meta.number.integer.decimal.diff constant.numeric.value.diff - 7: punctuation.separator.sequence.diff - 8: meta.number.integer.decimal.diff constant.numeric.value.diff - 9: punctuation.separator.sequence.diff - 10: meta.number.float.decimal.diff constant.numeric.value.diff - 11: punctuation.separator.decimal.diff - 12: storage.modifier.diff + 5: punctuation.separator.decimal.diff + 6: storage.modifier.diff diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 3c96520b41..7327ad886e 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -116,11 +116,11 @@ Unified Format https://www.gnu.org/software/diffutils/manual/html_node/Example-U --- lao 2002-02-21 23:30:39.942229878 -0800 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.from-file #^^ punctuation.definition.from-file -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.date.diff +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number +++ tzu 2002-02-21 23:30:50.442260588 -0800 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.to-file #^^ punctuation.definition.to-file -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.date.diff +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number @@ -1,7 +1,6 @@ -The Way that can be told of is not the eternal Way; -The name that can be named is not the eternal name. From 381380d48ae4d38b42219e92244144e90ec35385 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 042/127] [Diff] Consolidate Git stat line matches --- Diff/Git Diff.sublime-syntax | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 15164184dd..10d9713f53 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -151,21 +151,24 @@ contexts: - include: path-separators - match: \.{3} scope: keyword.operator.diff - - match: \| - scope: punctuation.separator.sequence.diff - - match: (Bin) (\d+) (->) (\d+) (bytes) + - match: |- + (?x: + (\|)[ ]+ + (?: + (Bin)[ ](\d+)[ ](->)[ ](\d+)[ ](bytes) # Binary files + | (\d+)[ ](\+*)(-*) # Text files + ) + ) captures: - 1: storage.type.diff - 2: meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff - 3: keyword.operator.logical.diff - 4: meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff - 5: constant.numeric.suffix.diff - - match: \d+ - scope: meta.number.integer.decimal.diff constant.numeric.value.diff - - match: \++ - scope: markup.inserted.diff - - match: -+ - scope: markup.deleted.diff + 1: punctuation.separator.sequence.diff + 2: storage.type.diff + 3: meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff + 4: keyword.operator.logical.diff + 5: meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff + 6: constant.numeric.suffix.diff + 7: meta.number.integer.decimal.diff constant.numeric.value.diff + 8: markup.inserted.diff + 9: markup.deleted.diff - match: ^(?= \d+ file) push: - include: pop-eol From 15ef595ee61ea697d7f01962f02903ce382ccaaa Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 043/127] [Diff] Change GNU links to anchors on full doc --- Diff/Diff.sublime-syntax | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index f95c984701..b9ad24baf0 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -1,7 +1,7 @@ %YAML 1.2 --- # https://www.sublimetext.com/docs/syntax.html -# https://www.gnu.org/software/diffutils/manual/html_node/index.html +# https://www.gnu.org/software/diffutils/manual/diffutils.html name: Diff version: 2 file_extensions: @@ -39,7 +39,7 @@ contexts: - include: deltas headers: - # https://www.gnu.org/software/diffutils/manual/html_node/Hunks.html + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks - match: ^-{3}{{eol}} scope: meta.separator.diff punctuation.definition.separator.diff @@ -77,7 +77,7 @@ contexts: 1: punctuation.separator.key-value.diff 2: meta.toc-list.file-name.diff - # https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified headers-unified: - match: ^(-{3})[ ](?!$) captures: @@ -100,7 +100,7 @@ contexts: line-ranges: - include: line-ranges-unified - # https://www.gnu.org/software/diffutils/manual/html_node/Hunks.html + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*{{eol}} scope: meta.diff.range.normal meta.range.normal.diff captures: @@ -108,7 +108,7 @@ contexts: 2: markup.inserted.diff 3: markup.deleted.diff 4: markup.changed.diff - # https://www.gnu.org/software/diffutils/manual/html_node/Example-Context.html + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - match: |- ^(?x: ( -{3})[ ].+[ ]( -{4}) # From range @@ -120,9 +120,10 @@ contexts: 2: punctuation.definition.range.diff 3: punctuation.definition.range.diff 4: punctuation.definition.range.diff - # TODO: diff3 https://www.gnu.org/software/diffutils/manual/html_node/Example-diff3-Normal.html + # TODO: diff3 + # # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-diff3-Normal - # https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified line-ranges-unified: - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*{{eol}} scope: meta.diff.range.unified meta.range.unified.diff @@ -133,9 +134,9 @@ contexts: 4: entity.name.section.diff deltas: - # https://www.gnu.org/software/diffutils/manual/html_node/Example-Context.html - # https://www.gnu.org/software/diffutils/manual/html_node/Example-Unified.html - # https://www.gnu.org/software/diffutils/manual/html_node/Example-Normal.html + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal - match: ^[+>] scope: punctuation.definition.inserted.diff push: line-inserted @@ -145,7 +146,7 @@ contexts: - match: ^[!|] scope: punctuation.definition.changed.diff push: line-changed - # https://www.gnu.org/software/diffutils/manual/html_node/Incomplete-Lines.html + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Incomplete-Lines - match: ^[\\/()] scope: punctuation.definition.comment.begin.diff push: line-ignored From c6e73b724d188936e90997fe6ee8fb960e5c8590 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 044/127] [Diff] Organize Git Diff with section headings --- Diff/Git Diff.sublime-syntax | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 10d9713f53..6382779c95 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -36,6 +36,8 @@ contexts: push: email-first-line - include: diffs +###[ EMAIL ]################################################################### + # https://git-scm.com/docs/git-format-patch#_description email-first-line: - meta_content_scope: comment.line.diff @@ -138,6 +140,8 @@ contexts: set: diffs - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message +###[ FRONT MATTER ]############################################################ + stat: - include: pop-before-diff-header - match: ^ (?=([^|]+[ ]+)\|) @@ -207,6 +211,8 @@ contexts: - match: \b(?:100)?755\b scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff +###[ DIFF ]#################################################################### + # https://git-scm.com/docs/diff-format#generate_patch_text_with_p diffs: - include: signature From c0750e40c9fbcc72ced086d604da158c53aade39 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 045/127] [Diff] Fix and Reformat first line matches --- Diff/Diff.sublime-syntax | 19 ++++++++++--------- Diff/Git Diff.sublime-syntax | 8 ++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index b9ad24baf0..c90bde8190 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -8,18 +8,19 @@ file_extensions: - diff - patch first_line_match: |- - (?x)^ - (===\ modified\ file - |==== \s* // .+ \s - \s .+ \s+ ==== - |Index:[ ] - |---\ [^%] - |\*\*\*.*\d{4}\s*$ - |\d+(,\d+)* (a|d|c) \d+(,\d+)* $ - ) + ^(?x: + ===\ modified\ file + | ==== \s* // .+ \s - \s .+ \s+ ==== + | Index:[ ] + | Prereq:[ ] + | ---\ [^%] + | \*\*\*.*\d{4}\s*$ + | \d+(,\d+)* [adc] \d+(,\d+)* $ + ) variables: git_first_line: (?:From \h{40} Mon Sep 17 00:00:00 2001) - eol: $\r?\n? + eol: (?:$\r?\n?) scope: source.diff contexts: diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 6382779c95..167fc9b6dd 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -12,10 +12,10 @@ file_extensions: - diff.mbox - patch.mbox first_line_match: |- - (?x)^ - (diff\ --git[ ] - |From \h{40} Mon Sep 17 00:00:00 2001 - ) + ^(?x: + diff[ ]--git[ ] + | From[ ]\h{40}[ ]Mon[ ]Sep[ ]17[ ]00:00:00[ ]2001 + ) variables: hash40: \h{40} From 5a03cf4b1a3f74fea64b2c113d7274e4af4aec95 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 046/127] [Diff] Change test file comment character --- Diff/tests/syntax_test_diff.diff | 211 ++++++++++++++------------ Diff/tests/syntax_test_git_diff.patch | 118 +++++++------- 2 files changed, 176 insertions(+), 153 deletions(-) diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 7327ad886e..b348e6cfc6 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -1,148 +1,141 @@ -# SYNTAX TEST "Packages/Diff/Diff.sublime-syntax" +\ SYNTAX TEST "Packages/Diff/Diff.sublime-syntax" --- Path to Original File -#^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.from-file meta.header.from-file.diff -# <- punctuation.definition.from-file.diff -#^^ punctuation.definition.from-file.diff +\^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.from-file meta.header.from-file.diff +\ <- punctuation.definition.from-file.diff +\^^ punctuation.definition.from-file.diff +++ Path to Modified File -#^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.to-file meta.header.to-file.diff -# <- punctuation.definition.to-file.diff -#^^ punctuation.definition.to-file.diff +\^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.to-file meta.header.to-file.diff +\ <- punctuation.definition.to-file.diff +\^^ punctuation.definition.to-file.diff 28a211 -#^^^^^ meta.diff.range.normal meta.range.normal.diff +\^^^^^ meta.diff.range.normal meta.range.normal.diff @@ -2,8 +2,11 @@ -#^^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff -# <- punctuation.definition.range.diff -#^ punctuation.definition.range.diff -# ^ - punctuation -# ^^^^^^^^^^ meta.toc-list.line-number.diff -# ^ - punctuation -# ^^ punctuation.definition.range.diff -# ^ - entity - punctuation +\^^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff +\ <- punctuation.definition.range.diff +\^ punctuation.definition.range.diff +\ ^ - punctuation +\ ^^^^^^^^^^ meta.toc-list.line-number.diff +\ ^ - punctuation +\ ^^ punctuation.definition.range.diff +\ ^ - entity - punctuation @@ -2,8 +2,11 @@ function_hint(int var) -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff -# <- punctuation.definition.range.diff -#^ punctuation.definition.range.diff -# ^ - punctuation -# ^^^^^^^^^^ meta.toc-list.line-number.diff -# ^ - punctuation -# ^^ punctuation.definition.range.diff -# ^ - entity - punctuation -# ^^^^^^^^^^^^^^^^^^^^^^ entity.name.section.diff -# ^ - entity.name.section.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff +\ <- punctuation.definition.range.diff +\^ punctuation.definition.range.diff +\ ^ - punctuation +\ ^^^^^^^^^^ meta.toc-list.line-number.diff +\ ^ - punctuation +\ ^^ punctuation.definition.range.diff +\ ^ - entity - punctuation +\ ^^^^^^^^^^^^^^^^^^^^^^ entity.name.section.diff +\ ^ - entity.name.section.diff ==== Something - Else ==== -#^^^^^^^^^^^^^ meta.header.from-file.diff -#^^^ punctuation.definition.from-file.diff -# ^^^^^^^^^^^^ meta.header.to-file.diff -# ^ punctuation.definition.to-file.diff -# ^^^^ punctuation.definition.to-file.diff +\^^^^^^^^^^^^^ meta.header.from-file.diff +\^^^ punctuation.definition.from-file.diff +\ ^^^^^^^^^^^^ meta.header.to-file.diff +\ ^ punctuation.definition.to-file.diff +\ ^^^^ punctuation.definition.to-file.diff --- Range ---- -#^^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff -# <- punctuation.definition.range.diff -#^^ punctuation.definition.range.diff -# ^^^^ punctuation.definition.range.diff +\^^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\ <- punctuation.definition.range.diff +\^^ punctuation.definition.range.diff +\ ^^^^ punctuation.definition.range.diff *** Range **** -#^^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff -# <- punctuation.definition.range.diff -#^^ punctuation.definition.range.diff -# ^^^^ punctuation.definition.range.diff +\^^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\ <- punctuation.definition.range.diff +\^^ punctuation.definition.range.diff +\ ^^^^ punctuation.definition.range.diff *************** -#^^^^^^^^^^^^^^ meta.separator.diff punctuation.definition.separator.diff +\^^^^^^^^^^^^^^ meta.separator.diff punctuation.definition.separator.diff **************** -#^^^^^^^^^^^^^^^ -meta.separator.diff punctuation.definition.separator.diff +\^^^^^^^^^^^^^^^ -meta.separator.diff punctuation.definition.separator.diff =================================================================== -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.separator.diff punctuation.definition.separator.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.separator.diff punctuation.definition.separator.diff ==================================================================== -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -meta.separator.diff punctuation.definition.separator.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.separator.diff punctuation.definition.separator.diff --- -#^^ meta.separator.diff -#^^ punctuation.definition.separator.diff +\^^ meta.separator.diff +\^^ punctuation.definition.separator.diff ---- -#^^^ -meta.separator.diff -#^^^ -punctuation.definition.separator.diff +\^^^ - meta.separator.diff +\^^^ - punctuation.definition.separator.diff Plain Text -#^^^^^^^^^ source.diff - markup +\^^^^^^^^^ source.diff - markup + Addition -# <- markup.inserted.diff punctuation.definition.inserted.diff -# ^^^^^^^^ markup.inserted.diff - meta.whitespace -# ^^ markup.inserted.diff meta.whitespace.trailing.diff +\ <- punctuation.definition.inserted.diff +\ ^^^^^^^^ markup.inserted.diff - meta.whitespace +\ ^^ markup.inserted.diff meta.whitespace.trailing.diff > Addition -# <- markup.inserted.diff punctuation.definition.inserted.diff -# ^^^^^^^^ markup.inserted.diff - meta.whitespace -# ^^ markup.inserted.diff meta.whitespace.trailing.diff +\ <- punctuation.definition.inserted.diff +\ ^^^^^^^^ markup.inserted.diff - meta.whitespace +\ ^^ markup.inserted.diff meta.whitespace.trailing.diff - Deletion -# <- markup.deleted.diff punctuation.definition.deleted.diff -# ^^^^^^^^ markup.deleted.diff - meta.whitespace -# ^^ markup.deleted.diff meta.whitespace.trailing.diff +\ <- punctuation.definition.deleted.diff +\ ^^^^^^^^ markup.deleted.diff - meta.whitespace +\ ^^ markup.deleted.diff meta.whitespace.trailing.diff < Deletion -# <- markup.deleted.diff punctuation.definition.deleted.diff -# ^^^^^^^^ markup.deleted.diff - meta.whitespace -# ^^ markup.deleted.diff meta.whitespace.trailing.diff +\ <- punctuation.definition.deleted.diff +\ ^^^^^^^^ markup.deleted.diff - meta.whitespace +\ ^^ markup.deleted.diff meta.whitespace.trailing.diff ! Modified -# <- markup.changed.diff punctuation.definition.changed.diff -# ^^^^^^^^ markup.changed.diff - meta.whitespace -# ^^ markup.changed.diff meta.whitespace.trailing.diff +\ <- punctuation.definition.changed.diff +\ ^^^^^^^^ markup.changed.diff - meta.whitespace +\ ^^ markup.changed.diff meta.whitespace.trailing.diff Index: value -#^^^^^^^^^^^ meta.diff.index meta.index.diff -# ^ punctuation.separator.key-value.diff -# ^^^^^ meta.toc-list.file-name.diff +\^^^^^^^^^^^ meta.diff.index meta.index.diff +\ ^ punctuation.separator.key-value.diff +\ ^^^^^ meta.toc-list.file-name.diff \ No newline at end of file -#^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line -# <- punctuation.definition.comment +\^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line +\ <- punctuation.definition.comment -Unified Format https://www.gnu.org/software/diffutils/manual/html_node/Example-Unified.html ---- lao 2002-02-21 23:30:39.942229878 -0800 -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.from-file -#^^ punctuation.definition.from-file -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number -+++ tzu 2002-02-21 23:30:50.442260588 -0800 -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.to-file -#^^ punctuation.definition.to-file -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number -@@ -1,7 +1,6 @@ --The Way that can be told of is not the eternal Way; --The name that can be named is not the eternal name. - The Nameless is the origin of Heaven and Earth; --The Named is the mother of all things. -+The named is the mother of all things. -+ - Therefore let there always be non-being, - so we may see their subtlety, - And let there always be being, -@@ -9,3 +8,6 @@ - The two are the same, - But after they are produced, - they have different names. -+They both may be called deep and profound. -+Deeper and more profound, -+The door of all subtleties! +Normal Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal +1,2d0 +< The Way that can be told of is not the eternal Way; +< The name that can be named is not the eternal name. +4c2,3 +< The Named is the mother of all things. +--- +> The named is the mother of all things. +> +11a11,13 +> They both may be called deep and profound. +> Deeper and more profound, +> The door of all subtleties! -Context Format https://www.gnu.org/software/diffutils/manual/html_node/Example-Context.html +Context Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context *** lao 2002-02-21 23:30:39.942229878 -0800 +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.from-file +\^^ punctuation.definition.from-file +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number --- tzu 2002-02-21 23:30:50.442260588 -0800 +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.to-file +\^^ punctuation.definition.to-file +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number *************** *** 1,7 **** - The Way that can be told of is not the eternal Way; @@ -168,3 +161,31 @@ Context Format https://www.gnu.org/software/diffutils/manual/html_node/Example-C + They both may be called deep and profound. + Deeper and more profound, + The door of all subtleties! + + +Unified Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified +--- lao 2002-02-21 23:30:39.942229878 -0800 +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.from-file +\^^ punctuation.definition.from-file +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number ++++ tzu 2002-02-21 23:30:50.442260588 -0800 +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.to-file +\^^ punctuation.definition.to-file +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number +@@ -1,7 +1,6 @@ +-The Way that can be told of is not the eternal Way; +-The name that can be named is not the eternal name. + The Nameless is the origin of Heaven and Earth; +-The Named is the mother of all things. ++The named is the mother of all things. ++ + Therefore let there always be non-being, + so we may see their subtlety, + And let there always be being, +@@ -9,3 +8,6 @@ + The two are the same, + But after they are produced, + they have different names. ++They both may be called deep and profound. ++Deeper and more profound, ++The door of all subtleties! diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index ad71fa330b..f740a8fce1 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -1,77 +1,79 @@ -# SYNTAX TEST "Packages/Diff/Git Diff.sublime-syntax" +\ SYNTAX TEST "Packages/Diff/Git Diff.sublime-syntax" From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001 -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.diff -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git From: Tony Luck -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.diff -#^^^ keyword -# ^ punctuation.separator.mapping.key-value.diff -# ^^^^^^^^^ meta.reference.user.git -# ^^^^^^^^^^^^^^^^^^^^^ meta.reference.email.git -# ^ punctuation.definition.reference.email.begin.git -# ^^^^^^^^^^^^^^^^^^^ entity.name.reference.email.git -# ^ punctuation.separator.email.git -# ^ punctuation.separator.domain.git -# ^ punctuation.definition.reference.email.end.git +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.diff +\^^^ keyword +\ ^ punctuation.separator.mapping.key-value.diff +\ ^^^^^^^^^ meta.reference.user.git +\ ^^^^^^^^^^^^^^^^^^^^^ meta.reference.email.git +\ ^ punctuation.definition.reference.email.begin.git +\ ^^^^^^^^^^^^^^^^^^^ entity.name.reference.email.git +\ ^ punctuation.separator.email.git +\ ^ punctuation.separator.domain.git +\ ^ punctuation.definition.reference.email.end.git Date: Tue, 13 Jul 2010 11:42:54 -0700 -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff -#^^^ keyword -# ^ punctuation.separator.mapping.key-value.diff -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.numeric.value.diff -# ^ punctuation.separator.sequence.diff -# ^ punctuation.separator.sequence.diff -# ^ punctuation.separator.sequence.diff -# ^ keyword.operator.arithmetic.diff -Subject: [PATCH 1/2] [IA64] Put ia64 config files on the Uwe Kleine-Koenig diet -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff -#^^^^^^ keyword -# ^ punctuation.separator.mapping.key-value.diff -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.diff -# ^^^^^^^^^^^ variable.annotation.diff -# ^ punctuation.definition.annotation.begin.diff -# ^ meta.number.integer.decimal.diff constant.numeric.value.diff -# ^ punctuation.separator.sequence.diff -# ^ meta.number.integer.decimal.diff constant.numeric.value.diff -# ^ punctuation.definition.annotation.end.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff +\^^^ keyword +\ ^ punctuation.separator.mapping.key-value.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.numeric.value.diff +\ ^ punctuation.separator.sequence.diff +\ ^ punctuation.separator.sequence.diff +\ ^ punctuation.separator.sequence.diff +\ ^ keyword.operator.arithmetic.diff +Subject: [PATCH v2 1/2] [IA64] Put ia64 config files on the Uwe Kleine-Koenig diet +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff +\ ^^ meta.annotation.patch-version.diff storage.modifier.diff +\ ^^^ meta.annotation.patch-sequence.diff +\^^^^^^ keyword +\ ^ punctuation.separator.mapping.key-value.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.diff +\ ^^^^^^^^^^^^^^ variable.annotation.diff +\ ^ punctuation.definition.annotation.begin.diff +\ ^ meta.number.integer.decimal.diff constant.numeric.value.diff +\ ^ punctuation.separator.sequence.diff +\ ^ meta.number.integer.decimal.diff constant.numeric.value.diff +\ ^ punctuation.definition.annotation.end.diff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff -#^^^^^^^^^^^ keyword.other.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff +\^^^^^^^^^^^ keyword.other.diff Content-Transfer-Encoding: 8bit arch/arm config files were slimmed down using a python script (See commit c2330e286f68f1c408b4aa6515ba49d57f05beae comment) -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git Do the same for ia64 so we can have sleek & trim looking --- Gemfile | 1 + -#^^^^^^^ entity.name.diff -# ^ punctuation.separator.sequence.diff -# ^ meta.number.integer.decimal.diff constant.numeric.value.diff -# ^ markup.inserted.diff +\^^^^^^^ entity.name.diff +\ ^ punctuation.separator.sequence.diff +\ ^ meta.number.integer.decimal.diff constant.numeric.value.diff +\ ^ markup.inserted.diff app/assets/images/logo.jpeg | Bin 0 -> 50966 bytes -#^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.diff -# ^ punctuation.separator.sequence.diff -# ^ punctuation.separator.sequence.diff -# ^ punctuation.separator.sequence.diff -# ^ punctuation.separator.sequence.diff -# ^^^ storage.type.diff -# ^ meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff -# ^^ keyword.operator.logical.diff -# ^^^^^ meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff -# ^^^^^ constant.numeric.suffix.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.diff +\ ^ punctuation.separator.sequence.diff +\ ^ punctuation.separator.sequence.diff +\ ^ punctuation.separator.sequence.diff +\ ^ punctuation.separator.sequence.diff +\ ^^^ storage.type.diff +\ ^ meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff +\ ^^ keyword.operator.logical.diff +\ ^^^^^ meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff +\ ^^^^^ constant.numeric.suffix.diff fonts/icomoon.eot | Bin 55452 -> 56000 bytes 3 files changed, 1 insertion(+) -#^ meta.number.integer.decimal.diff constant.numeric.value.diff -# ^ punctuation.separator.sequence.diff -# ^ meta.number.integer.decimal.diff constant.numeric.value.diff -# ^^^^^^^^^^^^ markup.inserted.diff -# ^ punctuation.definition.diff -# ^ punctuation.definition.diff +\^ meta.number.integer.decimal.diff constant.numeric.value.diff +\ ^ punctuation.separator.sequence.diff +\ ^ meta.number.integer.decimal.diff constant.numeric.value.diff +\ ^^^^^^^^^^^^ markup.inserted.diff +\ ^ punctuation.definition.diff +\ ^ punctuation.definition.diff diff --git a/Gemfile b/Gemfile index c661619..989efe8 100644 @@ -136,6 +138,6 @@ z%Wa1HBo8BxHy*z{cX&Jb82BXwx&+M#4hZQA{T2Qua$fYgm=m#P@rq0d0txF9UnK2G fPDyD Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 047/127] [Diff] Add blockquote and scissors to Git email --- Diff/Git Diff.sublime-syntax | 16 ++++++++++++++++ Diff/tests/syntax_test_git_diff.patch | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 167fc9b6dd..888c10597d 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -24,6 +24,7 @@ variables: month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' empty_line: ^(?=\r?\n) + scissors: (?:>8|8<) scope: source.diff.git contexts: @@ -131,6 +132,9 @@ contexts: email-body: - meta_content_scope: meta.block.git-body.diff + # https://git-scm.com/docs/git-mailinfo#Documentation/git-mailinfo.txt---scissors + - match: ^(?=--[ -]*{{scissors}}(?:{{scissors}}|[ -])*--\s*$) + set: [email-header, scissors-line] - match: ^(---)\r?\n captures: 1: punctuation.definition.section.diff @@ -139,6 +143,18 @@ contexts: - match: '^(?=Index: |diff -)' set: diffs - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message + - match: ^>+ + scope: punctuation.definition.blockquote.git + push: + - meta_scope: markup.quote.git + - include: pop-eol + - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message + + scissors-line: + - meta_scope: punctuation.section.block.git + - include: pop-eol + - match: '{{scissors}}' + scope: support.function.scissors.git ###[ FRONT MATTER ]############################################################ diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index f740a8fce1..48dea3be0e 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -49,6 +49,28 @@ arch/arm config files were slimmed down using a python script Do the same for ia64 so we can have sleek & trim looking +-- >8 ----- >8 ---- +\^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff punctuation.section.block.git +\ ^^ support.function.scissors.git +\ ^^ support.function.scissors.git +Subject: [RFC PATCH v3] How about this instead? +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff +\ ^^^ storage.modifier.diff +\ ^^ meta.annotation.patch-version.diff storage.modifier.diff +\^^^^^^ keyword +\ ^ punctuation.separator.mapping.key-value.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.diff +\ ^^^^^^^^^^^^^^ variable.annotation.diff +\ ^ punctuation.definition.annotation.begin.diff +\ ^ punctuation.definition.annotation.end.diff + +> Do the same for ia64 so we can have sleek & trim looking +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-body.diff markup.quote.git +\ <- punctuation.definition.blockquote.git + +Much better, no? +\^^^^^^^^^^^^^^^^ meta.block.git-body.diff + --- Gemfile | 1 + \^^^^^^^ entity.name.diff From fad1e98eb03d75e45ab8770c3e9c9fc2d3c38488 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 048/127] [Diff] Support Diff3 Normal mode --- Diff/Diff.sublime-syntax | 24 +++++++++++++++++-- Diff/tests/syntax_test_diff.diff | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index c90bde8190..a1876bc37f 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -24,6 +24,10 @@ variables: scope: source.diff contexts: + pop-immediately: + - match: '' + pop: 1 + pop-eol: - match: '{{eol}}' pop: 1 @@ -121,8 +125,24 @@ contexts: 2: punctuation.definition.range.diff 3: punctuation.definition.range.diff 4: punctuation.definition.range.diff - # TODO: diff3 - # # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-diff3-Normal + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-diff3-Normal + - match: ^====[1-3]?{{eol}} + scope: punctuation.section.block.diff + - match: ^([1-3])(:)(\d+(a)|\d+(?:(,)\d+)?(c)){{eol}} + scope: meta.mapping.diff + captures: + 1: meta.mapping.key.diff meta.number.integer.decimal.diff constant.numeric.value.diff + 2: punctuation.separator.key-value.diff + 3: meta.mapping.value.diff meta.diff.range.normal meta.range.normal.diff + 4: markup.inserted.diff + 5: punctuation.separator.sequence.diff + 6: markup.changed.diff + push: + - match: ^(?:\t| ) + push: line-changed + - match: ^ + pop: 1 + # - include: pop-immediately # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified line-ranges-unified: diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index b348e6cfc6..f018d51d35 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -189,3 +189,44 @@ Unified Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Exam +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! + + +Diff3 Normal Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-diff3-Normal +====2 +1:1,2c +3:1,2c + The Way that can be told of is not the eternal Way; + The name that can be named is not the eternal name. +2:0a +====1 +1:4c + The Named is the mother of all things. +2:2,3c +3:4,5c + The named is the mother of all things. + +====3 +1:8c +2:7c + so we may see their outcome. +3:9c + so we may see their result. +==== +1:11a +2:11,13c + They both may be called deep and profound. + Deeper and more profound, + The door of all subtleties! +3:13,14c + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan + + +Diff3 Edit Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Selecting-Which-Changes-to-Incorporate +11a + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +. +8c + so we may see their result. +. From 7c58155f0ed6ae66db23ee72c17f010bccb27a39 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 049/127] [Diff] Modify punctuation scopes --- Diff/Diff.sublime-syntax | 4 ++-- Diff/Git Diff.sublime-syntax | 4 ++-- Diff/tests/syntax_test_diff.diff | 13 ++++++------- Diff/tests/syntax_test_git_diff.patch | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index a1876bc37f..580d97c83f 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -46,14 +46,14 @@ contexts: headers: # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks - match: ^-{3}{{eol}} - scope: meta.separator.diff punctuation.definition.separator.diff + scope: meta.separator.diff punctuation.separator.block.diff - include: headers-unified - match: ^(\*{15}|={67}){{eol}} scope: meta.separator.diff captures: - 1: punctuation.definition.separator.diff + 1: punctuation.separator.block.diff - match: ^(\*{3})[ ](?!$) captures: 1: punctuation.definition.from-file.diff diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 888c10597d..bfdec5a385 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -137,7 +137,7 @@ contexts: set: [email-header, scissors-line] - match: ^(---)\r?\n captures: - 1: punctuation.definition.section.diff + 1: punctuation.section.block.diff set: [diffs, stat] # https://git-scm.com/docs/git-am#_discussion - match: '^(?=Index: |diff -)' @@ -352,6 +352,6 @@ contexts: # This is the Git version unless otherwise configured - match: ^(-- ){{eol}} captures: - 1: meta.separator.diff punctuation.definition.separator.diff + 1: meta.separator.diff punctuation.section.block.diff set: - meta_content_scope: comment.block.diff diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index f018d51d35..87b2df0c25 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -55,24 +55,23 @@ \ ^^^^ punctuation.definition.range.diff *************** -\^^^^^^^^^^^^^^ meta.separator.diff punctuation.definition.separator.diff +\^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff **************** -\^^^^^^^^^^^^^^^ -meta.separator.diff punctuation.definition.separator.diff +\^^^^^^^^^^^^^^^ - meta - punctuation =================================================================== -\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.separator.diff punctuation.definition.separator.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff ==================================================================== -\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.separator.diff punctuation.definition.separator.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta - punctuation --- \^^ meta.separator.diff -\^^ punctuation.definition.separator.diff +\^^ punctuation.separator.block.diff ---- -\^^^ - meta.separator.diff -\^^^ - punctuation.definition.separator.diff +\^^^ - meta - punctuation Plain Text \^^^^^^^^^ source.diff - markup diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index 48dea3be0e..ed030762df 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -160,6 +160,6 @@ z%Wa1HBo8BxHy*z{cX&Jb82BXwx&+M#4hZQA{T2Qua$fYgm=m#P@rq0d0txF9UnK2G fPDyD Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 050/127] [Diff] Add Git email subject RFC flag --- Diff/Git Diff.sublime-syntax | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index bfdec5a385..3e0dd32b8e 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -86,9 +86,10 @@ contexts: push: - meta_scope: meta.mapping.diff - meta_content_scope: markup.heading.diff - - match: (\[)PATCH + - match: (\[)(?:(RFC) )?PATCH captures: 1: punctuation.definition.annotation.begin.diff + 2: storage.modifier.diff push: - meta_scope: variable.annotation.diff - match: \] From 151888a90979e7673a740e91664034a655d075fb Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 051/127] [Diff] Split delta types for traditional Diff --- Diff/Diff.sublime-syntax | 35 ++++++++++++++++++++++++++++------- Diff/Git Diff.sublime-syntax | 7 ++++++- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 580d97c83f..c41fa2488d 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -155,20 +155,41 @@ contexts: 4: entity.name.section.diff deltas: - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal - - match: ^[+>] + - include: deltas-normal + - include: deltas-context + - include: deltas-unified + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal + deltas-normal: + - match: ^> scope: punctuation.definition.inserted.diff push: line-inserted - - match: ^[-<] + - match: ^< scope: punctuation.definition.deleted.diff push: line-deleted - - match: ^[!|] + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Incomplete-Lines + - match: ^[\\/] + scope: punctuation.definition.comment.begin.diff + push: line-ignored + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context + deltas-context: + # This is not precisely correct: Context Mode has a space after each +/-. + - include: deltas-unified + - match: ^! scope: punctuation.definition.changed.diff push: line-changed + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified + deltas-unified: + - match: ^\+ + scope: punctuation.definition.inserted.diff + push: line-inserted + - match: ^- + scope: punctuation.definition.deleted.diff + push: line-deleted # https://www.gnu.org/software/diffutils/manual/diffutils.html#Incomplete-Lines - - match: ^[\\/()] + - match: ^[\\/] scope: punctuation.definition.comment.begin.diff push: line-ignored diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 3e0dd32b8e..700830fe7a 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -325,7 +325,12 @@ contexts: - include: binary-deltas # TODO: Multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format - include: line-ranges-unified - - include: deltas + - include: deltas-unified + + deltas-unified: + - meta_prepend: true + - match: ^(?=-- {{eol}}) + pop: 1 # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c binary-deltas: From 6e749f4d5264a75561307ac44cb63061a7f7eb83 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 052/127] [Diff] Heavily refactor traditional Diff Add headers and roll-up contexts. --- Diff/Diff.sublime-syntax | 181 +++++++++++++++++++++---------- Diff/Git Diff.sublime-syntax | 2 +- Diff/tests/syntax_test_diff.diff | 56 +++++++--- 3 files changed, 166 insertions(+), 73 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index c41fa2488d..a526dafa78 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -24,6 +24,9 @@ variables: scope: source.diff contexts: + +###[ PROTOTYPES ]############################################################## + pop-immediately: - match: '' pop: 1 @@ -36,51 +39,105 @@ contexts: - match: (?={{eol}}) pop: 1 + line-ranges: + - include: line-ranges-normal + - include: line-ranges-context + - include: line-ranges-unified + + deltas: + - include: deltas-normal + - include: deltas-context + - include: deltas-unified + + unified: + - include: headers-unified + - include: line-ranges-unified + - include: deltas-unified + + diff3: + - include: diff3-normal + main: - match: ^(?={{git_first_line}}) push: Git Diff.sublime-syntax#email-first-line + - include: leading-text - include: line-ranges - include: headers - include: deltas + - include: diff3 - headers: - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks - - match: ^-{3}{{eol}} - scope: meta.separator.diff punctuation.separator.block.diff - - - include: headers-unified +###[ LEADING TEXT ]############################################################ - - match: ^(\*{15}|={67}){{eol}} - scope: meta.separator.diff + leading-text: + - match: ^(Index)(:)[ \t]* captures: - 1: punctuation.separator.block.diff - - match: ^(\*{3})[ ](?!$) + 1: meta.mapping.key.diff keyword.other.diff + 2: punctuation.separator.key-value.diff + push: + - 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 + - match: ^(Prereq)(:)[ \t]* captures: - 1: punctuation.definition.from-file.diff + 1: meta.mapping.key.diff keyword.other.diff + 2: punctuation.separator.key-value.diff push: - - meta_scope: meta.diff.header.from-file meta.header.from-file.diff + - meta_scope: meta.mapping.diff + - meta_content_scope: meta.mapping.value.diff string.unquoted.diff - include: pop-eol - - include: dev-null - include: path-separators - - include: date + +###[ HEADERS ]################################################################# + + headers: + - include: headers-context + - include: headers-unified - match: ^(={4}) .+(?= - ) scope: meta.diff.header.from-file meta.header.from-file.diff captures: 1: punctuation.definition.from-file.diff push: - - match: ' (-) .* (={4}){{eol}}' - scope: meta.diff.header.to-file meta.header.to-file.diff + - match: '( (-) )(.* (={4})){{eol}}' captures: - 1: punctuation.definition.to-file.diff - 2: punctuation.definition.to-file.diff + 1: meta.header.diff + 2: punctuation.separator.sequence.diff + 3: meta.diff.header.to-file meta.header.to-file.diff + 4: punctuation.definition.to-file.diff pop: 1 - - match: '' - pop: 1 - - match: ^Index(:) (.+){{eol}} - scope: meta.diff.index meta.index.diff + - include: pop-immediately + - match: ^(\*{15}|={67}){{eol}} + scope: meta.separator.diff + captures: + 1: punctuation.separator.block.diff + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Context + headers-context: + - match: ^(\*{3})[ ](?!$) captures: - 1: punctuation.separator.key-value.diff - 2: meta.toc-list.file-name.diff + 1: punctuation.definition.from-file.diff + push: headers-context-from-file + + headers-context-from-file: + - meta_scope: meta.diff.header.from-file meta.header.from-file.diff + - match: '{{eol}}' + set: maybe-headers-context-to-file + - include: dev-null + - include: path-separators + - include: date + maybe-headers-context-to-file: + - match: ^(-{3})[ ](?!$) + captures: + 1: punctuation.definition.to-file.diff + push: headers-context-to-file + - match: ^ + pop: 1 + headers-context-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 # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified headers-unified: @@ -103,46 +160,32 @@ contexts: - include: path-separators - include: date - line-ranges: - - include: line-ranges-unified - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks - - match: ^\d+(?:(,)\d+)*(?:(a)|(d)|(c))\d+(?:(,)\d+)*{{eol}} +###[ RANGES ]################################################################## + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks + line-ranges-normal: + - match: ^-{3}{{eol}} + scope: meta.separator.diff punctuation.separator.block.diff + - match: ^\d+(?:(,)\d+)*(a|d|c)\d+(?:(,)\d+)*{{eol}} scope: meta.diff.range.normal meta.range.normal.diff captures: 1: punctuation.separator.sequence.diff - 2: markup.inserted.diff - 3: markup.deleted.diff - 4: markup.changed.diff - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context + 2: support.function.diff + 3: punctuation.separator.sequence.diff + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context + line-ranges-context: - match: |- ^(?x: ( -{3})[ ].+[ ]( -{4}) # From range | (\*{3})[ ].+[ ](\*{4}) # To range ){{eol}} - scope: meta.diff.range.context meta.range.context.diff - captures: - 1: punctuation.definition.range.diff - 2: punctuation.definition.range.diff - 3: punctuation.definition.range.diff - 4: punctuation.definition.range.diff - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-diff3-Normal - - match: ^====[1-3]?{{eol}} - scope: punctuation.section.block.diff - - match: ^([1-3])(:)(\d+(a)|\d+(?:(,)\d+)?(c)){{eol}} - scope: meta.mapping.diff + scope: meta.diff.range.context meta.range.context.diff meta.toc-list.line-number.diff captures: - 1: meta.mapping.key.diff meta.number.integer.decimal.diff constant.numeric.value.diff - 2: punctuation.separator.key-value.diff - 3: meta.mapping.value.diff meta.diff.range.normal meta.range.normal.diff - 4: markup.inserted.diff - 5: punctuation.separator.sequence.diff - 6: markup.changed.diff - push: - - match: ^(?:\t| ) - push: line-changed - - match: ^ - pop: 1 - # - include: pop-immediately + 1: punctuation.definition.range.begin.diff + 2: punctuation.definition.range.end.diff + 3: punctuation.definition.range.begin.diff + 4: punctuation.definition.range.end.diff # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified line-ranges-unified: @@ -154,10 +197,7 @@ contexts: 3: punctuation.definition.range.diff 4: entity.name.section.diff - deltas: - - include: deltas-normal - - include: deltas-context - - include: deltas-unified +###[ DELTAS ]################################################################## # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal deltas-normal: @@ -214,6 +254,29 @@ contexts: - match: '[ \t]*(?=$)' scope: meta.whitespace.trailing.diff +###[ DIFF3 ]################################################################### + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-diff3-Normal + diff3-normal: + - match: ^====[1-3]?{{eol}} + scope: punctuation.section.block.diff + - match: ^([1-3])(:)(\d+(a)|\d+(?:(,)\d+)?(c)){{eol}} + scope: meta.mapping.diff + captures: + 1: meta.mapping.key.diff meta.number.integer.decimal.diff constant.numeric.value.diff + 2: punctuation.separator.key-value.diff + 3: meta.mapping.value.diff meta.diff.range.normal meta.range.normal.diff + 4: support.function.diff + 5: punctuation.separator.sequence.diff + 6: support.function.diff + push: + - match: ^(?:\t| ) + push: line-changed + - match: ^ + pop: 1 + +###[ COMPONENTS ]############################################################## + dev-null: - match: /dev/null\b scope: constant.language.null.diff diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 700830fe7a..29dc4d503f 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -157,7 +157,7 @@ contexts: - match: '{{scissors}}' scope: support.function.scissors.git -###[ FRONT MATTER ]############################################################ +###[ LEADING TEXT ]############################################################ stat: - include: pop-before-diff-header diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 87b2df0c25..f7b9137c82 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -35,24 +35,25 @@ \ ^^^^^^^^^^^^^^^^^^^^^^ entity.name.section.diff \ ^ - entity.name.section.diff -==== Something - Else ==== +==== From-File - To-File ==== +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header \^^^^^^^^^^^^^ meta.header.from-file.diff \^^^ punctuation.definition.from-file.diff -\ ^^^^^^^^^^^^ meta.header.to-file.diff -\ ^ punctuation.definition.to-file.diff -\ ^^^^ punctuation.definition.to-file.diff +\ ^^^^^^^^^^^^ meta.header.to-file.diff +\ ^ punctuation +\ ^^^^ punctuation.definition.to-file.diff --- Range ---- \^^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff -\ <- punctuation.definition.range.diff -\^^ punctuation.definition.range.diff -\ ^^^^ punctuation.definition.range.diff +\ <- punctuation.definition.range.begin.diff +\^^ punctuation.definition.range.begin.diff +\ ^^^^ punctuation.definition.range.end.diff *** Range **** \^^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff -\ <- punctuation.definition.range.diff -\^^ punctuation.definition.range.diff -\ ^^^^ punctuation.definition.range.diff +\ <- punctuation.definition.range.begin.diff +\^^ punctuation.definition.range.begin.diff +\ ^^^^ punctuation.definition.range.end.diff *************** \^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff @@ -101,10 +102,11 @@ Plain Text \ ^^^^^^^^ markup.changed.diff - meta.whitespace \ ^^ markup.changed.diff meta.whitespace.trailing.diff -Index: value -\^^^^^^^^^^^ meta.diff.index meta.index.diff +Index: lao +\^^^^^^^^^^ meta.diff.index meta.index.diff +\^^^^ meta.mapping.key.diff keyword.other.diff \ ^ punctuation.separator.key-value.diff -\ ^^^^^ meta.toc-list.file-name.diff +\ ^^^ meta.mapping.value.diff meta.toc-list.file-name.diff \ No newline at end of file \^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line @@ -131,29 +133,57 @@ Context Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Exam \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.from-file \^^ punctuation.definition.from-file \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number + +\ Only consider `---` to be a "to" if it follows a `***` +*** lao 2002-02-21 23:30:39.942229878 -0800 --- tzu 2002-02-21 23:30:50.442260588 -0800 \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.header.to-file \^^ punctuation.definition.to-file \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number *************** +\^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff *** 1,7 **** +\^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\^^ punctuation.definition.range.begin.diff +\ ^^^^ punctuation.definition.range.end.diff - The Way that can be told of is not the eternal Way; +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff +\ <- punctuation.definition.deleted.diff - The name that can be named is not the eternal name. +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff +\ <- punctuation.definition.deleted.diff The Nameless is the origin of Heaven and Earth; +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - markup ! The Named is the mother of all things. +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.diff +\ <- punctuation.definition.changed.diff Therefore let there always be non-being, +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - markup so we may see their subtlety, And let there always be being, --- 1,6 ---- +\^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\^^ punctuation.definition.range.begin.diff +\ ^^^^ punctuation.definition.range.end.diff The Nameless is the origin of Heaven and Earth; ! The named is the mother of all things. +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.diff +\ <- punctuation.definition.changed.diff ! +\ <- markup.changed.diff punctuation.definition.changed.diff Therefore let there always be non-being, so we may see their subtlety, And let there always be being, *************** +\^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff *** 9,11 **** +\^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\^^ punctuation.definition.range.begin.diff +\ ^^^^ punctuation.definition.range.end.diff --- 8,13 ---- +\^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\^^ punctuation.definition.range.begin.diff +\ ^^^^ punctuation.definition.range.end.diff The two are the same, But after they are produced, they have different names. From 0b78d379ffddeae00a5200610b7e7de6cd4af2bd Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 053/127] [Diff] Scope ranges in hunk headers Also include the function name in GoTo [Diff] Unified line ranges double-push [Diff] Context line ranges double-push --- Diff/Diff.sublime-syntax | 53 ++++++++++++++++++++++---------- Diff/tests/syntax_test_diff.diff | 29 ++++++++++------- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index a526dafa78..d4ef3d8889 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -175,27 +175,46 @@ contexts: # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context line-ranges-context: - - match: |- - ^(?x: - ( -{3})[ ].+[ ]( -{4}) # From range - | (\*{3})[ ].+[ ](\*{4}) # To range - ){{eol}} - scope: meta.diff.range.context meta.range.context.diff meta.toc-list.line-number.diff - captures: - 1: punctuation.definition.range.begin.diff - 2: punctuation.definition.range.end.diff - 3: punctuation.definition.range.begin.diff - 4: punctuation.definition.range.end.diff + - match: ^([-*]){3}(?= .+ \1{4}{{eol}}) + scope: punctuation.definition.range.begin.diff + push: inside-line-ranges-context + + inside-line-ranges-context: + - meta_scope: meta.diff.range.context meta.range.context.diff meta.toc-list.hunk.diff + - include: pop-eol + - match: \1{4} + scope: punctuation.definition.range.end.diff + pop: 1 + - include: line-range-span # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified line-ranges-unified: - - match: ^(@@)\s*(.+?)\s*(@@)\s*(.*?)\s*{{eol}} - scope: meta.diff.range.unified meta.range.unified.diff + - match: ^(@@)(?=[^@\n]+\1(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [hunk-name, inside-line-ranges-unified] + + inside-line-ranges-unified: + - meta_scope: meta.diff.range.unified meta.range.unified.diff meta.toc-list.hunk.diff + - include: pop-eol + - match: \1 + scope: punctuation.definition.range.end.diff + pop: 1 + - include: line-range-span + - match: '[+-](?=\d)' + scope: support.function.diff + + hunk-name: + - include: pop-eol + - match: '[ \t]+' + scope: meta.toc-list.hunk.diff + - match: \S.+?(?=\s*{{eol}}) + scope: meta.toc-list.hunk.diff entity.name.section.diff + + line-range-span: + - match: \d+(?:(,)\d+)? captures: - 1: punctuation.definition.range.diff - 2: meta.toc-list.line-number.diff - 3: punctuation.definition.range.diff - 4: entity.name.section.diff + 1: punctuation.separator.sequence.diff ###[ DELTAS ]################################################################## diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index f7b9137c82..3e6b551f00 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -15,22 +15,22 @@ @@ -2,8 +2,11 @@ \^^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff -\ <- punctuation.definition.range.diff -\^ punctuation.definition.range.diff +\ <- punctuation.definition.range.begin.diff +\^ punctuation.definition.range.begin.diff \ ^ - punctuation -\ ^^^^^^^^^^ meta.toc-list.line-number.diff +\ ^^^^^^^^^^ meta.toc-list.hunk.diff \ ^ - punctuation -\ ^^ punctuation.definition.range.diff +\ ^^ punctuation.definition.range.end.diff \ ^ - entity - punctuation @@ -2,8 +2,11 @@ function_hint(int var) -\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff -\ <- punctuation.definition.range.diff -\^ punctuation.definition.range.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.toc-list.hunk.diff +\^^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff +\ <- punctuation.definition.range.begin.diff +\^ punctuation.definition.range.begin.diff \ ^ - punctuation -\ ^^^^^^^^^^ meta.toc-list.line-number.diff \ ^ - punctuation -\ ^^ punctuation.definition.range.diff +\ ^^ punctuation.definition.range.end.diff \ ^ - entity - punctuation \ ^^^^^^^^^^^^^^^^^^^^^^ entity.name.section.diff \ ^ - entity.name.section.diff @@ -143,7 +143,8 @@ Context Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Exam *************** \^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff *** 1,7 **** -\^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\ ^ punctuation.separator \^^ punctuation.definition.range.begin.diff \ ^^^^ punctuation.definition.range.end.diff - The Way that can be told of is not the eternal Way; @@ -162,8 +163,9 @@ Context Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Exam so we may see their subtlety, And let there always be being, --- 1,6 ---- -\^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff \^^ punctuation.definition.range.begin.diff +\ ^ punctuation.separator \ ^^^^ punctuation.definition.range.end.diff The Nameless is the origin of Heaven and Earth; ! The named is the mother of all things. @@ -178,10 +180,12 @@ Context Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Exam \^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff *** 9,11 **** \^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\ ^ punctuation.separator \^^ punctuation.definition.range.begin.diff \ ^^^^ punctuation.definition.range.end.diff --- 8,13 ---- \^^^^^^^^^^^^ meta.diff.range.context meta.range.context.diff +\ ^ punctuation.separator \^^ punctuation.definition.range.begin.diff \ ^^^^ punctuation.definition.range.end.diff The two are the same, @@ -202,6 +206,9 @@ Unified Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Exam \^^ punctuation.definition.to-file \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.number @@ -1,7 +1,6 @@ +\^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff +\^ punctuation.definition.range.begin.diff +\ ^^ punctuation.definition.range.end.diff -The Way that can be told of is not the eternal Way; -The name that can be named is not the eternal name. The Nameless is the origin of Heaven and Earth; From 181821973fd817b537e9dd026d25ea39bfa7d777 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 054/127] [Diff] Path constants --- Diff/Diff.sublime-syntax | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index d4ef3d8889..59f681171d 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -303,6 +303,10 @@ contexts: path-separators: - match: /|\\ scope: punctuation.separator.sequence.diff + - match: \B\.\.(?=/|\\) + scope: constant.other.path.parent.diff + - match: \B\.(?=/|\\) + scope: constant.other.path.self.diff date: # 1970-01-01 00:00:00 +0000 From 5f14a7ea4294c1c1289b2a55b9546bfb756a2c3e Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 055/127] [Diff] Diff3 edit mode --- Diff/Diff.sublime-syntax | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 59f681171d..0addb8b043 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -56,6 +56,7 @@ contexts: diff3: - include: diff3-normal + - include: diff3-edit main: - match: ^(?={{git_first_line}}) @@ -64,7 +65,7 @@ contexts: - include: line-ranges - include: headers - include: deltas - - include: diff3 + - include: diff3-normal ###[ LEADING TEXT ]############################################################ @@ -294,6 +295,36 @@ contexts: - match: ^ pop: 1 + # This conflicts with non-diff3 Normal mode, so it's off by default + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Selecting-Which-Changes-to-Incorporate + diff3-edit: + - match: ^(\d+)(a){{eol}} + captures: + 1: meta.diff.range.normal meta.range.normal.diff + 2: support.function.diff + push: + - meta_content_scope: meta.block.diff markup.inserted.diff + - include: diff3-edit-end + - match: ^(\d+)(d){{eol}} + captures: + 1: meta.diff.range.normal meta.range.normal.diff + 2: support.function.diff + push: + - meta_content_scope: meta.block.diff markup.deleted.diff + - include: diff3-edit-end + - match: ^(\d+)(c){{eol}} + captures: + 1: meta.diff.range.normal meta.range.normal.diff + 2: support.function.diff + push: + - meta_content_scope: meta.block.diff markup.modified.diff + - include: diff3-edit-end + + diff3-edit-end: + - match: ^\.$ + scope: punctuation.section.block.end.diff + pop: 1 + ###[ COMPONENTS ]############################################################## dev-null: From b6a37ba1af51951ceeea7c3f1ef2b6b637e17c81 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 056/127] [Diff] Sort syntax headers --- Diff/Diff.sublime-syntax | 4 +++- Diff/Git Diff.sublime-syntax | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 0addb8b043..5ef5e6f5b1 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -3,10 +3,13 @@ # https://www.sublimetext.com/docs/syntax.html # https://www.gnu.org/software/diffutils/manual/diffutils.html name: Diff +scope: source.diff version: 2 + file_extensions: - diff - patch + first_line_match: |- ^(?x: ===\ modified\ file @@ -22,7 +25,6 @@ variables: git_first_line: (?:From \h{40} Mon Sep 17 00:00:00 2001) eol: (?:$\r?\n?) -scope: source.diff contexts: ###[ PROTOTYPES ]############################################################## diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 29dc4d503f..cbe4e4c37a 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -4,13 +4,16 @@ # https://git-scm.com/docs/git-format-patch # https://git-scm.com/docs/diff-format name: Git Diff +scope: source.diff.git version: 2 extends: Diff.sublime-syntax + file_extensions: - diff.eml - patch.eml - diff.mbox - patch.mbox + first_line_match: |- ^(?x: diff[ ]--git[ ] @@ -26,7 +29,6 @@ variables: empty_line: ^(?=\r?\n) scissors: (?:>8|8<) -scope: source.diff.git contexts: pop-before-diff-header: - match: ^(?=diff --git\b) From 7473575f28c26e3a3d2d17e040003600b52afa3f Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 057/127] [Diff] Create a conflict syntax It's rudimentary, but it works. --- Diff/Conflict.sublime-syntax | 57 +++++++++++++ Diff/tests/syntax_test_conflict.conflict | 102 +++++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 Diff/Conflict.sublime-syntax create mode 100644 Diff/tests/syntax_test_conflict.conflict diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax new file mode 100644 index 0000000000..7248aa2a8a --- /dev/null +++ b/Diff/Conflict.sublime-syntax @@ -0,0 +1,57 @@ +%YAML 1.2 +--- +# https://www.sublimetext.com/docs/syntax.html +# https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 +name: Conflict +scope: source.conflict +version: 2 + +file_extensions: + - conflict + +variables: + eol: (?:$\r?\n?) + +contexts: + pop-new-section: + - match: ^(?=>{5,}|<{5,}|={5,}|\|{5,}) + pop: 1 + + main: + # Old + - match: ^(<{5,})\s*(\S.*?)\s*{{eol}} + captures: + 1: punctuation.section.block.begin.conflict + 2: entity.name.section.conflict + push: + - meta_scope: meta.block.conflict + - meta_content_scope: markup.deleted.conflict + - match: ^(?:<{5,}|>{5,}) + scope: invalid.illegal.conflict + - include: pop-new-section + # Index + - match: ^(\|{5,})\s*(\S.*?)\s*{{eol}} + captures: + 1: punctuation.definition.comment.begin.conflict + 2: entity.name.section.conflict + push: + - meta_scope: meta.block.conflict + - meta_content_scope: comment.block.conflict + - match: ^(?:>{5,}|<{5,}) + scope: invalid.illegal.conflict + - include: pop-new-section + # New + - match: ^(={5,})\s*{{eol}} + captures: + 1: punctuation.separator.section.conflict + push: + - meta_scope: meta.block.conflict + - meta_content_scope: markup.inserted.conflict + - match: ^(?:={5,}|<{5,}|\|{5,}) + scope: invalid.illegal.conflict + - match: ^(>{5,})\s*(\S.*?)\s*{{eol}} + captures: + 1: punctuation.section.block.end.conflict + 2: entity.name.section.conflict + pop: 1 + - include: pop-new-section diff --git a/Diff/tests/syntax_test_conflict.conflict b/Diff/tests/syntax_test_conflict.conflict new file mode 100644 index 0000000000..b841befeb1 --- /dev/null +++ b/Diff/tests/syntax_test_conflict.conflict @@ -0,0 +1,102 @@ +\ SYNTAX TEST "Packages/Diff/Conflict.sublime-syntax" + +https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 +<<<<<<< A +\^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.begin.conflict +\ ^ - entity - punctuation +\ ^ entity.name.section.conflict +\ ^ - entity +lines from A +\^^^^^^^^^^^^ meta.block.conflict markup.deleted.conflict - meta.block meta.block +======= +\^^^^^^ meta.block.conflict punctuation.separator.section.conflict - markup +lines from B +\^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict +>>>>>>> B +\^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.end.conflict +\ ^ - entity +\ ^ entity.name.section.conflict +\ ^ - entity +context context +\^^^^^^^^^^^^^^^ - meta.block + +<<<<<<< A +lines from A +||||||| B +\^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup +\^^^^^^ punctuation.definition.comment.begin.conflict +\ ^ - entity - punctuation +\ ^ entity.name.section.conflict +\ ^ - entity +lines from B +\^^^^^^^^^^^^ meta.block.conflict comment.block.conflict - meta.block meta.block - markup +======= +\^^^^^^ meta.block.conflict punctuation.separator.section.conflict - meta.block meta.block - markup +> +\ <- meta.block.conflict markup.inserted.conflict - punctuation +< +\ <- meta.block.conflict markup.inserted.conflict - punctuation +<<<<< +\^^^^ meta.block.conflict markup.inserted.conflict invalid.illegal.conflict +lines from C +\^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict +>>>>>>> C +context context +\ <- - meta.block + +<<<<<<< tzu +======= +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +>>>>>>> tao + +<<<<<<< lao +||||||| tzu +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> tao + +<<<<<<< lao +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> tao + + +https://www.gnu.org/software/diffutils/manual/diffutils.html#Generating-the-Merged-Output-Directly +<<<<<<< tzu +======= +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +>>>>>>> tao +The Nameless is the origin of Heaven and Earth; +The Named is the mother of all things. +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their result. +The two are the same, +But after they are produced, + they have different names. +<<<<<<< lao +||||||| tzu +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> tao + +If you have questions, please +<<<<<<< HEAD +open an issue +======= +ask your question in IRC. +>>>>>>> branch-a From 5f499cea67bafd91b964fb66828a91f9b448f683 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 058/127] [Diff] Rename `00000` hash to constant --- Diff/Git Diff.sublime-syntax | 4 ++-- Diff/tests/syntax_test_git_diff.patch | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index cbe4e4c37a..c572e55413 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -312,10 +312,10 @@ contexts: ) captures: 1: keyword.other.diff - 2: markup.deleted.diff + 2: constant.language.null.diff 3: constant.other.hash.git 4: punctuation.separator.sequence.diff - 5: markup.deleted.diff + 5: constant.language.null.diff 6: constant.other.hash.git push: - include: pop-before-eol diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index ed030762df..c7af1d869e 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -112,6 +112,11 @@ index c661619..989efe8 100644 diff --git a/app/assets/images/logo.jpeg b/app/assets/images/logo.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..064fa38be3ecd426a3c8977ed43df627c6f6f229 +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff +\^^^^ keyword.other.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.language.null.diff +\ ^^ punctuation.separator.sequence.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git GIT binary patch literal 50966 zcmbT6RZtv2x1a}i2o6CLAUMHc&=7(LcbCE49fAa#;4l!}9R?j7La@Qz-3jh4+5Goz @@ -126,9 +131,15 @@ v97b_p1peNmKNs|WZ3Z9xD7de_7qxsD`+5QY01Jai0{XNQKl(o6fIt7)0U9~_ literal 0 HcmV?d00001 +\^^^^^^^^^^ meta.block.delta.diff constant.language.null.diff diff --git a/fonts/icomoon.eot b/fonts/icomoon.eot index 626bad58a4b2cec0becf93a6473ea19a74752019..7267a0c132111ef91e957a67aaaa5621a1bbb428 100644 +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff +\^^^^ keyword.other.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git +\ ^^ punctuation.separator.sequence.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git GIT binary patch delta 946 zcmX|9ZA=qq9Dn|I?H#Qx?YOoF?X}vMyMxvid$(O*s7OGVb_JbiA;1QuVCVu$R+158 @@ -158,6 +169,8 @@ zX3iKk`N=iy&EnUc8SA-c@j38?@MZAT2qp=B6Z$5+M1(_Rk*J+mg1DcAg`}L+25C3x zGMQttesXi Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 059/127] [Diff] Experiment with combined diff --- Diff/Git Diff.sublime-syntax | 44 ++++++++++++++-- .../tests/syntax_test_git_diff_combined.patch | 50 +++++++++++++++++++ 2 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 Diff/tests/syntax_test_git_diff_combined.patch diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index c572e55413..ae0451f24e 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -16,7 +16,7 @@ file_extensions: first_line_match: |- ^(?x: - diff[ ]--git[ ] + diff[ ]--(?:git|combined|cc)[ ] | From[ ]\h{40}[ ]Mon[ ]Sep[ ]17[ ]00:00:00[ ]2001 ) @@ -235,7 +235,7 @@ contexts: # https://git-scm.com/docs/diff-format#generate_patch_text_with_p diffs: - include: signature - - match: ^(diff) ((--)git) + - match: ^(diff) ((--)(?:git|combined|cc)) captures: 1: variable.function.diff 2: variable.parameter.diff @@ -302,7 +302,7 @@ contexts: (index)[ ] (?: (0{7,40}) # Empty hash - | ({{hash}}) # File content hash + | ({{hash}}(?:,{{hash}})*) # File content hash (hacky combined diff multiples) )\b (\.\.) # Double-dot separator (?: @@ -325,7 +325,7 @@ contexts: - meta_content_scope: meta.block.delta.diff - include: pop-before-diff-header - include: binary-deltas - # TODO: Multi-parent diff https://git-scm.com/docs/diff-format#_combined_diff_format + - include: line-ranges-combined - include: line-ranges-unified - include: deltas-unified @@ -363,3 +363,39 @@ contexts: 1: meta.separator.diff punctuation.section.block.diff set: - meta_content_scope: comment.block.diff + +###[ COMBINED DIFF ]########################################################### + + # https://git-scm.com/docs/diff-format#_combined_diff_format + line-ranges-combined: + - include: line-range-combined-2 + + line-range-combined-2: + - match: ^(@@@)(?=[^@\n]+\1(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [deltas-combined-2, hunk-name, inside-line-ranges-combined-2] + + inside-line-ranges-combined-2: + - meta_scope: meta.diff.range.combined meta.range.combined.diff meta.toc-list.hunk.diff + - include: pop-eol + - match: \1 + scope: punctuation.definition.range.end.diff + pop: 1 + - include: line-range-span + - match: '[+-](?=\d)' + scope: support.function.diff + + deltas-combined-2: + - match: ^$ + pop: 1 + - match: ^[ ]{2} + - match: ^[+ ]{2} + scope: punctuation.definition.inserted.diff + push: line-inserted + - match: ^[- ]{2} + scope: punctuation.definition.deleted.diff + push: line-deleted + - match: ^[+-]{2} + scope: punctuation.definition.deleted.diff + push: line-changed diff --git a/Diff/tests/syntax_test_git_diff_combined.patch b/Diff/tests/syntax_test_git_diff_combined.patch new file mode 100644 index 0000000000..069f543ceb --- /dev/null +++ b/Diff/tests/syntax_test_git_diff_combined.patch @@ -0,0 +1,50 @@ +\ SYNTAX TEST "Packages/Diff/Git Diff.sublime-syntax" +diff --combined describe.c +index fabadb8,cc95eb0..4866510 644 +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff +\^^^^ keyword.other.diff +\ ^^^^^^^ constant.other.hash.git +\ ^ punctuation.separator.sequence.git +\ ^^^^^^^ constant.other.hash.git +\ ^^ keyword.operator.logical.git +\ ^^^^^^^ constant.other.hash.git +\ ^^^ meta.number.integer.octal.diff constant.numeric.value.diff +--- a/describe.c +\^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.from-file meta.header.from-file.diff +\^^ punctuation.definition.from-file.diff ++++ b/describe.c +\^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.to-file meta.header.to-file.diff +\^^ punctuation.definition.to-file.diff +@@@ -98,20 -98,12 +98,20 @@@ +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff meta.diff.range.combined meta.range.combined.diff meta.toc-list.hunk.diff + return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff - markup + } + +- static void describe(char *arg) +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff markup.deleted.diff + -static void describe(struct commit *cmit, int last_one) +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff markup.deleted.diff +++static void describe(char *arg, int last_one) +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff markup.inserted.diff + { + + unsigned char sha1[20]; +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff markup.inserted.diff + + struct commit *cmit; +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff markup.inserted.diff + struct commit_list *list; +\ <- meta.block.delta.diff - markup +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff - markup + static int initialized = 0; + struct commit_name *n; + + + if (get_sha1(arg, sha1) < 0) + + usage(describe_usage); + + cmit = lookup_commit_reference(sha1); + + if (!cmit) + + usage(describe_usage); + + + if (!initialized) { ++- initialized = 1; +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff markup.changed.diff + for_each_ref(get_name); From e17ecd200b7d2e9bcddc6dee4c923cf115b656c0 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 060/127] [Diff] Support combined diff out to 5 parents --- Diff/Git Diff.sublime-syntax | 93 ++++++++++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 9 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index ae0451f24e..42a4805e1c 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -30,6 +30,10 @@ variables: scissors: (?:>8|8<) contexts: + pop-empty-line: + - match: '{{empty_line}}' + pop: 1 + pop-before-diff-header: - match: ^(?=diff --git\b) pop: 1 @@ -369,14 +373,11 @@ contexts: # https://git-scm.com/docs/diff-format#_combined_diff_format line-ranges-combined: - include: line-range-combined-2 + - include: line-range-combined-3 + - include: line-range-combined-4 + - include: line-range-combined-5 - line-range-combined-2: - - match: ^(@@@)(?=[^@\n]+\1(?:\s|$)) - captures: - 1: punctuation.definition.range.begin.diff - push: [deltas-combined-2, hunk-name, inside-line-ranges-combined-2] - - inside-line-ranges-combined-2: + inside-line-ranges-combined: - meta_scope: meta.diff.range.combined meta.range.combined.diff meta.toc-list.hunk.diff - include: pop-eol - match: \1 @@ -386,9 +387,14 @@ contexts: - match: '[+-](?=\d)' scope: support.function.diff + line-range-combined-2: + - match: ^(@@{2})(?=[^@\n]+\1(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [deltas-combined-2, hunk-name, inside-line-ranges-combined] + deltas-combined-2: - - match: ^$ - pop: 1 + - include: pop-empty-line - match: ^[ ]{2} - match: ^[+ ]{2} scope: punctuation.definition.inserted.diff @@ -396,6 +402,75 @@ contexts: - match: ^[- ]{2} scope: punctuation.definition.deleted.diff push: line-deleted + - match: ^[\\/ ]{2} + scope: punctuation.definition.comment.begin.diff + push: line-ignored - match: ^[+-]{2} + scope: punctuation.definition.changed.diff + push: line-changed + + line-range-combined-3: + - match: ^(@@{3})(?=[^@\n]+\1(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [deltas-combined-3, hunk-name, inside-line-ranges-combined] + + deltas-combined-3: + - include: pop-empty-line + - match: ^[ ]{3} + - match: ^[+ ]{3} + scope: punctuation.definition.inserted.diff + push: line-inserted + - match: ^[- ]{3} scope: punctuation.definition.deleted.diff + push: line-deleted + - match: ^[\\/ ]{3} + scope: punctuation.definition.comment.begin.diff + push: line-ignored + - match: ^[+-]{3} + scope: punctuation.definition.changed.diff + push: line-changed + + line-range-combined-4: + - match: ^(@@{4})(?=[^@\n]+\1(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [deltas-combined-4, hunk-name, inside-line-ranges-combined] + + deltas-combined-4: + - include: pop-empty-line + - match: ^[ ]{4} + - match: ^[+ ]{4} + scope: punctuation.definition.inserted.diff + push: line-inserted + - match: ^[- ]{4} + scope: punctuation.definition.deleted.diff + push: line-deleted + - match: ^[\\/ ]{4} + scope: punctuation.definition.comment.begin.diff + push: line-ignored + - match: ^[+-]{4} + scope: punctuation.definition.changed.diff + push: line-changed + + line-range-combined-5: + - match: ^(@@{5})(?=[^@\n]+\1(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [deltas-combined-5, hunk-name, inside-line-ranges-combined] + + deltas-combined-5: + - include: pop-empty-line + - match: ^[ ]{5} + - match: ^[+ ]{5} + scope: punctuation.definition.inserted.diff + push: line-inserted + - match: ^[- ]{5} + scope: punctuation.definition.deleted.diff + push: line-deleted + - match: ^[\\/ ]{5} + scope: punctuation.definition.comment.begin.diff + push: line-ignored + - match: ^[+-]{5} + scope: punctuation.definition.changed.diff push: line-changed From 8ce239883f03c14da154b7022020ac705af1ddce Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 061/127] [Diff] Push into context for `index` file header --- Diff/Git Diff.sublime-syntax | 40 +++++++++++++-------------- Diff/tests/syntax_test_git_diff.patch | 6 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 42a4805e1c..d35ad3ad1e 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -38,6 +38,18 @@ contexts: - match: ^(?=diff --git\b) pop: 1 + hash-empty: + - match: '0{7,40}' + scope: constant.language.null.git + + hash: + - match: '{{hash}}' + scope: constant.other.hash.git + + hash40: + - match: '{{hash40}}' + scope: constant.other.hash.git + main: - match: ^(?={{git_first_line}}) push: email-first-line @@ -301,29 +313,17 @@ contexts: 1: constant.numeric.value.git 2: constant.numeric.suffix.git # index .. - - match: |- - ^(?x: - (index)[ ] - (?: - (0{7,40}) # Empty hash - | ({{hash}}(?:,{{hash}})*) # File content hash (hacky combined diff multiples) - )\b - (\.\.) # Double-dot separator - (?: - (0{7,40}) # Empty hash - | ({{hash}}) # File content hash - )\b - ) - captures: - 1: keyword.other.diff - 2: constant.language.null.diff - 3: constant.other.hash.git - 4: punctuation.separator.sequence.diff - 5: constant.language.null.diff - 6: constant.other.hash.git + - match: ^index(?= [0-9a-f,.]+) + scope: keyword.other.diff push: - include: pop-before-eol - include: file-modes + - include: hash-empty + - include: hash + - match: \, + scope: punctuation.separator.sequence.git + - match: \.\. + scope: punctuation.separator.sequence.git diff-content: - meta_content_scope: meta.block.delta.diff diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index c7af1d869e..982dd28b18 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -114,8 +114,8 @@ new file mode 100644 index 0000000000000000000000000000000000000000..064fa38be3ecd426a3c8977ed43df627c6f6f229 \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff \^^^^ keyword.other.diff -\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.language.null.diff -\ ^^ punctuation.separator.sequence.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.language.null.git +\ ^^ punctuation.separator.sequence.git \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git GIT binary patch literal 50966 @@ -138,7 +138,7 @@ index 626bad58a4b2cec0becf93a6473ea19a74752019..7267a0c132111ef91e957a67aaaa5621 \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff \^^^^ keyword.other.diff \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git -\ ^^ punctuation.separator.sequence.diff +\ ^^ punctuation.separator.sequence.git \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git GIT binary patch delta 946 From 030c9a9e6aa138ff885179d825fe0834f3ad06bd Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 062/127] [Diff] Add more combined diff file headers --- Diff/Git Diff.sublime-syntax | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index d35ad3ad1e..c823231bbe 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -50,6 +50,13 @@ contexts: - match: '{{hash40}}' scope: constant.other.hash.git + separator-comma: + - match: \, + scope: punctuation.separator.sequence.git + + separator-twodot: + - match: \.\. + scope: punctuation.separator.sequence.git main: - match: ^(?={{git_first_line}}) push: email-first-line @@ -288,12 +295,22 @@ contexts: - meta_content_scope: markup.deleted.diff - include: pop-before-eol - include: file-modes + - include: separator-comma # new file mode - match: ^(?=new file mode) push: - meta_content_scope: markup.inserted.diff - include: pop-before-eol - include: file-modes + # mode ,.. (for combined diff) + - match: ^mode(?= [106475,.]+) + scope: keyword.other.diff + push: + - include: pop-before-eol + - include: file-modes + - include: separator-twodot + # Combined mode can have multiple pre-commits + - include: separator-comma # copy from # copy to # rename from @@ -320,10 +337,9 @@ contexts: - include: file-modes - include: hash-empty - include: hash - - match: \, - scope: punctuation.separator.sequence.git - - match: \.\. - scope: punctuation.separator.sequence.git + - include: separator-twodot + # Combined mode can have multiple pre-commits + - include: separator-comma diff-content: - meta_content_scope: meta.block.delta.diff From 4e838d077390ee37cc3e41c3fb03b57f2116d7f4 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 063/127] [Diff] Centralize components section Change .. to keyword.operator --- Diff/Git Diff.sublime-syntax | 51 +++++++++++++++------------ Diff/tests/syntax_test_git_diff.patch | 4 +-- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index c823231bbe..9159633b9c 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -28,35 +28,21 @@ variables: base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' empty_line: ^(?=\r?\n) scissors: (?:>8|8<) + # https://git-scm.com/docs/git-am#_discussion + next_diff_header: '(?=Index: |diff -)' contexts: + +###[ PROTOTYPES ]############################################################## + pop-empty-line: - match: '{{empty_line}}' pop: 1 pop-before-diff-header: - - match: ^(?=diff --git\b) + - match: ^{{next_diff_header}} pop: 1 - hash-empty: - - match: '0{7,40}' - scope: constant.language.null.git - - hash: - - match: '{{hash}}' - scope: constant.other.hash.git - - hash40: - - match: '{{hash40}}' - scope: constant.other.hash.git - - separator-comma: - - match: \, - scope: punctuation.separator.sequence.git - - separator-twodot: - - match: \.\. - scope: punctuation.separator.sequence.git main: - match: ^(?={{git_first_line}}) push: email-first-line @@ -165,8 +151,7 @@ contexts: captures: 1: punctuation.section.block.diff set: [diffs, stat] - # https://git-scm.com/docs/git-am#_discussion - - match: '^(?=Index: |diff -)' + - match: ^{{next_diff_header}} set: diffs - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message - match: ^>+ @@ -490,3 +475,25 @@ contexts: - match: ^[+-]{5} scope: punctuation.definition.changed.diff push: line-changed + +###[ COMPONENTS ]############################################################## + + hash-empty: + - match: '0{7,40}' + scope: constant.language.null.git + + hash: + - match: '{{hash}}' + scope: constant.other.hash.git + + hash40: + - match: '{{hash40}}' + scope: constant.other.hash.git + + separator-comma: + - match: \, + scope: punctuation.separator.sequence.git + + separator-twodot: + - match: \.\. + scope: keyword.operator.logical.git diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index 982dd28b18..aa7b60414d 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..064fa38be3ecd426a3c8977ed43df627 \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff \^^^^ keyword.other.diff \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.language.null.git -\ ^^ punctuation.separator.sequence.git +\ ^^ keyword.operator.logical.git \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git GIT binary patch literal 50966 @@ -138,7 +138,7 @@ index 626bad58a4b2cec0becf93a6473ea19a74752019..7267a0c132111ef91e957a67aaaa5621 \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff \^^^^ keyword.other.diff \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git -\ ^^ punctuation.separator.sequence.git +\ ^^ keyword.operator.logical.git \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git GIT binary patch delta 946 From 23fd62c0b802b25a3e4068cc2687b600ce2b1c1c Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 064/127] [Diff] More accurate trailing whitespace --- Diff/Diff.sublime-syntax | 25 +++++++++++++++---------- Diff/tests/syntax_test_diff.diff | 2 ++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 5ef5e6f5b1..bcd7858442 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -223,24 +223,26 @@ contexts: # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal deltas-normal: - - match: ^> + - match: ^> ? scope: punctuation.definition.inserted.diff push: line-inserted - - match: ^< + - match: ^< ? scope: punctuation.definition.deleted.diff push: line-deleted - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Incomplete-Lines - - match: ^[\\/] - scope: punctuation.definition.comment.begin.diff - push: line-ignored + - include: incomplete-line # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context deltas-context: - # This is not precisely correct: Context Mode has a space after each +/-. - - include: deltas-unified - - match: ^! + - match: ^\+ ? + scope: punctuation.definition.inserted.diff + push: line-inserted + - match: ^- ? + scope: punctuation.definition.deleted.diff + push: line-deleted + - match: ^! ? scope: punctuation.definition.changed.diff push: line-changed + - include: incomplete-line # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified deltas-unified: @@ -250,7 +252,10 @@ contexts: - match: ^- scope: punctuation.definition.deleted.diff push: line-deleted - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Incomplete-Lines + - include: incomplete-line + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Incomplete-Lines + incomplete-line: - match: ^[\\/] scope: punctuation.definition.comment.begin.diff push: line-ignored diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 3e6b551f00..740f93e805 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -122,6 +122,7 @@ Normal Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Examp --- > The named is the mother of all things. > +\^ - meta.whitespace 11a11,13 > They both may be called deep and profound. > Deeper and more profound, @@ -173,6 +174,7 @@ Context Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Exam \ <- punctuation.definition.changed.diff ! \ <- markup.changed.diff punctuation.definition.changed.diff +\^ - meta.whitespace Therefore let there always be non-being, so we may see their subtlety, And let there always be being, From 9ce9e8992b192fe1e89e6e9dbf8b1627811a7080 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:05 -0500 Subject: [PATCH 065/127] [Diff] Tweak date separator scope --- Diff/Diff.sublime-syntax | 16 ++++++++-------- Diff/Git Diff.sublime-syntax | 6 +++--- Diff/tests/syntax_test_git_diff.patch | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index bcd7858442..806f0cb1c1 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -351,19 +351,19 @@ contexts: - match: \b1970(-)01(-)01 0?0(:)00(:)00(?:(\.)0+)?(?:[ ]([+-]?0000|UTC))? scope: meta.date.diff constant.language.null.diff captures: - 1: punctuation.separator.sequence.diff - 2: punctuation.separator.sequence.diff - 3: punctuation.separator.sequence.diff - 4: punctuation.separator.sequence.diff + 1: punctuation.separator.date.diff + 2: punctuation.separator.date.diff + 3: punctuation.separator.date.diff + 4: punctuation.separator.date.diff 5: punctuation.separator.decimal.diff 6: storage.modifier.diff # 2002-02-21 23:30:50.442260588 -0800 - match: \b\d{4}(-)\d\d(-)\d\d \d?\d(:)\d\d(:)\d\d(?:(\.)\d+)?(?:[ ]([+-]?\d{4}))? scope: meta.date.diff meta.number.integer.decimal.diff constant.numeric.value.diff captures: - 1: punctuation.separator.sequence.diff - 2: punctuation.separator.sequence.diff - 3: punctuation.separator.sequence.diff - 4: punctuation.separator.sequence.diff + 1: punctuation.separator.date.diff + 2: punctuation.separator.date.diff + 3: punctuation.separator.date.diff + 4: punctuation.separator.date.diff 5: punctuation.separator.decimal.diff 6: storage.modifier.diff diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 9159633b9c..6dc0b3213e 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -125,9 +125,9 @@ contexts: - match: '{{day3}}(,) [0-3]?\d {{month3}} \d{4} \d\d(:)\d\d(:)\d\d(?: ([+-])\d{4})?' scope: constant.numeric.value.diff captures: - 1: punctuation.separator.sequence.diff - 2: punctuation.separator.sequence.diff - 3: punctuation.separator.sequence.diff + 1: punctuation.separator.date.diff + 2: punctuation.separator.date.diff + 3: punctuation.separator.date.diff 4: keyword.operator.arithmetic.diff - include: pop-before-eol # Other headers diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index aa7b60414d..a07ed1d791 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -19,9 +19,9 @@ Date: Tue, 13 Jul 2010 11:42:54 -0700 \^^^ keyword \ ^ punctuation.separator.mapping.key-value.diff \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.numeric.value.diff -\ ^ punctuation.separator.sequence.diff -\ ^ punctuation.separator.sequence.diff -\ ^ punctuation.separator.sequence.diff +\ ^ punctuation.separator.date.diff +\ ^ punctuation.separator.date.diff +\ ^ punctuation.separator.date.diff \ ^ keyword.operator.arithmetic.diff Subject: [PATCH v2 1/2] [IA64] Put ia64 config files on the Uwe Kleine-Koenig diet \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff From fdad09dd1aee233a4483162094db28cb10adacd7 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:06 -0500 Subject: [PATCH 066/127] [Diff] Prepare for SHA-256 Git --- Diff/Diff.sublime-syntax | 5 ++++- Diff/Git Diff.sublime-syntax | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 806f0cb1c1..a2fc729769 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -22,7 +22,10 @@ first_line_match: |- ) variables: - git_first_line: (?:From \h{40} Mon Sep 17 00:00:00 2001) + hash64: '[0-9a-fA-F]{64}' + hash40: '[0-9a-fA-F]{40}' + hash_full: (?:{{hash40}}|{{hash64}}) + git_first_line: (?:From {{hash_full}} Mon Sep 17 00:00:00 2001) eol: (?:$\r?\n?) contexts: diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 6dc0b3213e..5c1ddcea7f 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -17,12 +17,13 @@ file_extensions: first_line_match: |- ^(?x: diff[ ]--(?:git|combined|cc)[ ] - | From[ ]\h{40}[ ]Mon[ ]Sep[ ]17[ ]00:00:00[ ]2001 + | From [ ] + (?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64}) # Commit SHA + [ ]Mon[ ]Sep[ ]17[ ]00:00:00[ ]2001 # Magic date ) variables: - hash40: \h{40} - hash: \h{7,40} + hash: '[0-9a-fA-F]{7,64}' day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' @@ -53,7 +54,7 @@ contexts: # https://git-scm.com/docs/git-format-patch#_description email-first-line: - meta_content_scope: comment.line.diff - - match: '{{hash40}}' + - match: '{{hash_full}}' scope: constant.other.hash.git - match: \n|$ set: email-header @@ -320,7 +321,7 @@ contexts: push: - include: pop-before-eol - include: file-modes - - include: hash-empty + - include: hash-empty-content - include: hash - include: separator-twodot # Combined mode can have multiple pre-commits @@ -478,16 +479,16 @@ contexts: ###[ COMPONENTS ]############################################################## - hash-empty: - - match: '0{7,40}' + hash-empty-content: + - match: '0{7,64}' scope: constant.language.null.git hash: - match: '{{hash}}' scope: constant.other.hash.git - hash40: - - match: '{{hash40}}' + hash-full-length: + - match: '{{hash_full}}' scope: constant.other.hash.git separator-comma: From 2be2f6b20956af1d139cc850dcd2bf73dcde285b Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:06 -0500 Subject: [PATCH 067/127] [Diff] Arabic numbers only in Git --- Diff/Git Diff.sublime-syntax | 34 +++++++++++++++++---------- Diff/tests/syntax_test_git_diff.patch | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 5c1ddcea7f..f3d445f735 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -107,9 +107,9 @@ contexts: - match: \] scope: punctuation.definition.annotation.end.diff pop: 1 - - match: \bv\d+\b + - match: \bv[0-9]+\b scope: meta.annotation.patch-version.diff storage.modifier.diff - - match: (\d+)(/)(\d+) + - match: ([0-9]+)(/)([0-9]+) scope: meta.annotation.patch-sequence.diff captures: 1: meta.number.integer.decimal.diff constant.numeric.value.diff @@ -123,13 +123,23 @@ contexts: 2: punctuation.separator.mapping.key-value.diff push: - meta_scope: meta.mapping.diff - - match: '{{day3}}(,) [0-3]?\d {{month3}} \d{4} \d\d(:)\d\d(:)\d\d(?: ([+-])\d{4})?' - scope: constant.numeric.value.diff + - match: |- + (?x: + {{day3}}(,) [ ] # Day of week + [0-3]?[0-9] [ ] # Day of month + {{month3}} [ ] # Month + [0-9]{4} [ ] # Year + [0-9]{2}(:) # Hour + [0-9]{2}(:) # Minute + [0-9]{2} # Second + (?:[ ]([+-][0-9]{4}))? # Optional UTC offset + ) + scope: meta.date.diff constant.numeric.value.diff captures: 1: punctuation.separator.date.diff 2: punctuation.separator.date.diff 3: punctuation.separator.date.diff - 4: keyword.operator.arithmetic.diff + 4: storage.modifier.diff - include: pop-before-eol # Other headers - match: ^\b([\w-]+)\b(:) @@ -187,8 +197,8 @@ contexts: (?x: (\|)[ ]+ (?: - (Bin)[ ](\d+)[ ](->)[ ](\d+)[ ](bytes) # Binary files - | (\d+)[ ](\+*)(-*) # Text files + (Bin)[ ]([0-9]+)[ ](->)[ ]([0-9]+)[ ](bytes) # Binary files + | ([0-9]+)[ ](\+*)(-*) # Text files ) ) captures: @@ -201,10 +211,10 @@ contexts: 7: meta.number.integer.decimal.diff constant.numeric.value.diff 8: markup.inserted.diff 9: markup.deleted.diff - - match: ^(?= \d+ file) + - match: ^(?= [0-9]+ file) push: - include: pop-eol - - match: \d+ + - match: '[0-9]+' scope: meta.number.integer.decimal.diff constant.numeric.value.diff - match: ',' scope: punctuation.separator.sequence.diff @@ -310,7 +320,7 @@ contexts: - match: ^(?:dis)?similarity index push: - include: pop-before-eol - - match: (100|[1-9]?\d)(%) + - match: (100|[1-9]?[0-9])(%) scope: meta.number.integer.decimal.git captures: 1: constant.numeric.value.git @@ -345,7 +355,7 @@ contexts: - match: ^GIT binary patch scope: keyword.other.diff push: - - match: ^(delta|literal) (\d+) + - match: ^(delta|literal) ([0-9]+) captures: 1: support.function.diff 2: meta.number.integer.decimal.diff constant.numeric.value.diff @@ -386,7 +396,7 @@ contexts: scope: punctuation.definition.range.end.diff pop: 1 - include: line-range-span - - match: '[+-](?=\d)' + - match: '[+-](?=[0-9])' scope: support.function.diff line-range-combined-2: diff --git a/Diff/tests/syntax_test_git_diff.patch b/Diff/tests/syntax_test_git_diff.patch index a07ed1d791..edc529eaea 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Diff/tests/syntax_test_git_diff.patch @@ -22,7 +22,7 @@ Date: Tue, 13 Jul 2010 11:42:54 -0700 \ ^ punctuation.separator.date.diff \ ^ punctuation.separator.date.diff \ ^ punctuation.separator.date.diff -\ ^ keyword.operator.arithmetic.diff +\ ^^^^^ storage.modifier.diff Subject: [PATCH v2 1/2] [IA64] Put ia64 config files on the Uwe Kleine-Koenig diet \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff \ ^^ meta.annotation.patch-version.diff storage.modifier.diff From cd733ba8451ebfe63b35450b6471283e9748b632 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:06 -0500 Subject: [PATCH 068/127] [Diff] Fix backrefs incompatible with sregex --- Diff/Diff.sublime-syntax | 7 +++++-- Diff/Git Diff.sublime-syntax | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index a2fc729769..a776f43fbf 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -181,7 +181,10 @@ contexts: # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context line-ranges-context: - - match: ^([-*]){3}(?= .+ \1{4}{{eol}}) + - match: ^(-){3}(?= .+ -{4}{{eol}}) + scope: punctuation.definition.range.begin.diff + push: inside-line-ranges-context + - match: ^(\*){3}(?= .+ \*{4}{{eol}}) scope: punctuation.definition.range.begin.diff push: inside-line-ranges-context @@ -195,7 +198,7 @@ contexts: # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified line-ranges-unified: - - match: ^(@@)(?=[^@\n]+\1(?:\s|$)) + - match: ^(@@)(?=[^@\n]+@@(?:\s|$)) captures: 1: punctuation.definition.range.begin.diff push: [hunk-name, inside-line-ranges-unified] diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index f3d445f735..960b794b35 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -400,7 +400,7 @@ contexts: scope: support.function.diff line-range-combined-2: - - match: ^(@@{2})(?=[^@\n]+\1(?:\s|$)) + - match: ^(@@{2})(?=[^@\n]+@@{2}(?:\s|$)) captures: 1: punctuation.definition.range.begin.diff push: [deltas-combined-2, hunk-name, inside-line-ranges-combined] @@ -422,7 +422,7 @@ contexts: push: line-changed line-range-combined-3: - - match: ^(@@{3})(?=[^@\n]+\1(?:\s|$)) + - match: ^(@@{3})(?=[^@\n]+@@{3}(?:\s|$)) captures: 1: punctuation.definition.range.begin.diff push: [deltas-combined-3, hunk-name, inside-line-ranges-combined] @@ -444,7 +444,7 @@ contexts: push: line-changed line-range-combined-4: - - match: ^(@@{4})(?=[^@\n]+\1(?:\s|$)) + - match: ^(@@{4})(?=[^@\n]+@@{4}(?:\s|$)) captures: 1: punctuation.definition.range.begin.diff push: [deltas-combined-4, hunk-name, inside-line-ranges-combined] @@ -466,7 +466,7 @@ contexts: push: line-changed line-range-combined-5: - - match: ^(@@{5})(?=[^@\n]+\1(?:\s|$)) + - match: ^(@@{5})(?=[^@\n]+@@{5}(?:\s|$)) captures: 1: punctuation.definition.range.begin.diff push: [deltas-combined-5, hunk-name, inside-line-ranges-combined] From 8f611467679acb21c55e1c705556cb96636f32b7 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:06 -0500 Subject: [PATCH 069/127] [Diff] Tweak conflict scopes --- Diff/Conflict.sublime-syntax | 4 ++-- Diff/tests/syntax_test_conflict.conflict | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax index 7248aa2a8a..df5f6f5bc2 100644 --- a/Diff/Conflict.sublime-syntax +++ b/Diff/Conflict.sublime-syntax @@ -32,7 +32,7 @@ contexts: # Index - match: ^(\|{5,})\s*(\S.*?)\s*{{eol}} captures: - 1: punctuation.definition.comment.begin.conflict + 1: punctuation.section.block.begin.conflict 2: entity.name.section.conflict push: - meta_scope: meta.block.conflict @@ -43,7 +43,7 @@ contexts: # New - match: ^(={5,})\s*{{eol}} captures: - 1: punctuation.separator.section.conflict + 1: punctuation.section.block.begin.conflict push: - meta_scope: meta.block.conflict - meta_content_scope: markup.inserted.conflict diff --git a/Diff/tests/syntax_test_conflict.conflict b/Diff/tests/syntax_test_conflict.conflict index b841befeb1..e51f947935 100644 --- a/Diff/tests/syntax_test_conflict.conflict +++ b/Diff/tests/syntax_test_conflict.conflict @@ -10,7 +10,7 @@ https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 lines from A \^^^^^^^^^^^^ meta.block.conflict markup.deleted.conflict - meta.block meta.block ======= -\^^^^^^ meta.block.conflict punctuation.separator.section.conflict - markup +\^^^^^^ meta.block.conflict punctuation.section.block.begin.conflict - meta.block meta.block - markup lines from B \^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict >>>>>>> B @@ -26,18 +26,18 @@ context context lines from A ||||||| B \^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup -\^^^^^^ punctuation.definition.comment.begin.conflict +\^^^^^^ punctuation.section.block.begin.conflict \ ^ - entity - punctuation \ ^ entity.name.section.conflict \ ^ - entity lines from B \^^^^^^^^^^^^ meta.block.conflict comment.block.conflict - meta.block meta.block - markup ======= -\^^^^^^ meta.block.conflict punctuation.separator.section.conflict - meta.block meta.block - markup +\^^^^^^ meta.block.conflict punctuation.section.block.begin.conflict - meta.block meta.block - markup > -\ <- meta.block.conflict markup.inserted.conflict - punctuation +\ <- meta.block.conflict markup.inserted.conflict - punctuation - invalid < -\ <- meta.block.conflict markup.inserted.conflict - punctuation +\ <- meta.block.conflict markup.inserted.conflict - punctuation - invalid <<<<< \^^^^ meta.block.conflict markup.inserted.conflict invalid.illegal.conflict lines from C From d7e29fd8d47bc9c1280eb8e5bf673ae45aa816f4 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:06 -0500 Subject: [PATCH 070/127] [Diff] First-line syntax for git-send-email --- Diff/Diff.sublime-syntax | 8 +++++++- Diff/Git Diff.sublime-syntax | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index a776f43fbf..c24f08fd84 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -25,7 +25,13 @@ variables: hash64: '[0-9a-fA-F]{64}' hash40: '[0-9a-fA-F]{40}' hash_full: (?:{{hash40}}|{{hash64}}) - git_first_line: (?:From {{hash_full}} Mon Sep 17 00:00:00 2001) + git_first_line: |- + ^(?x: + From [ ] \w+@z [ ] + Thu [ ] Jan [ ]{2} 1 [ ] 00:00:00 [ ] 1970 # git-send-email + | From [ ] {{hash_full}} [ ] + Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch + ) eol: (?:$\r?\n?) contexts: diff --git a/Diff/Git Diff.sublime-syntax b/Diff/Git Diff.sublime-syntax index 960b794b35..fb43a214c1 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Diff/Git Diff.sublime-syntax @@ -17,9 +17,10 @@ file_extensions: first_line_match: |- ^(?x: diff[ ]--(?:git|combined|cc)[ ] - | From [ ] - (?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64}) # Commit SHA - [ ]Mon[ ]Sep[ ]17[ ]00:00:00[ ]2001 # Magic date + | From [ ] \w+@z [ ] + Thu [ ] Jan [ ]{2} 1 [ ] 00:00:00 [ ] 1970 # git-send-email + | From [ ] (?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64}) [ ] + Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch ) variables: From 2eb4f8f2dd04b68c155ae6614c6e5f55438efb94 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Sat, 7 Dec 2024 15:55:06 -0500 Subject: [PATCH 071/127] [Diff] Move Git Diff to Git Formats --- Diff/Diff.sublime-syntax | 2 +- {Diff => Git Formats}/Git Diff.sublime-syntax | 6 +++--- {Diff => Git Formats}/tests/syntax_test_git_diff.patch | 2 +- .../tests/syntax_test_git_diff_combined.patch | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename {Diff => Git Formats}/Git Diff.sublime-syntax (98%) rename {Diff => Git Formats}/tests/syntax_test_git_diff.patch (99%) rename {Diff => Git Formats}/tests/syntax_test_git_diff_combined.patch (97%) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index c24f08fd84..ef4e01172f 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -71,7 +71,7 @@ contexts: main: - match: ^(?={{git_first_line}}) - push: Git Diff.sublime-syntax#email-first-line + push: Packages/Git Formats/Git Diff.sublime-syntax#email-first-line - include: leading-text - include: line-ranges - include: headers diff --git a/Diff/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax similarity index 98% rename from Diff/Git Diff.sublime-syntax rename to Git Formats/Git Diff.sublime-syntax index fb43a214c1..4fc2d9ac21 100644 --- a/Diff/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -6,7 +6,7 @@ name: Git Diff scope: source.diff.git version: 2 -extends: Diff.sublime-syntax +extends: Packages/Diff/Diff.sublime-syntax file_extensions: - diff.eml @@ -165,13 +165,13 @@ contexts: set: [diffs, stat] - match: ^{{next_diff_header}} set: diffs - - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message + - include: Git Commit Message.sublime-syntax#commit-message - match: ^>+ scope: punctuation.definition.blockquote.git push: - meta_scope: markup.quote.git - include: pop-eol - - include: Packages/Git Formats/Git Commit Message.sublime-syntax#commit-message + - include: Git Commit Message.sublime-syntax#commit-message scissors-line: - meta_scope: punctuation.section.block.git diff --git a/Diff/tests/syntax_test_git_diff.patch b/Git Formats/tests/syntax_test_git_diff.patch similarity index 99% rename from Diff/tests/syntax_test_git_diff.patch rename to Git Formats/tests/syntax_test_git_diff.patch index edc529eaea..578f62205a 100644 --- a/Diff/tests/syntax_test_git_diff.patch +++ b/Git Formats/tests/syntax_test_git_diff.patch @@ -1,4 +1,4 @@ -\ SYNTAX TEST "Packages/Diff/Git Diff.sublime-syntax" +\ SYNTAX TEST "Packages/Git Formats/Git Diff.sublime-syntax" From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001 \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.diff \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git diff --git a/Diff/tests/syntax_test_git_diff_combined.patch b/Git Formats/tests/syntax_test_git_diff_combined.patch similarity index 97% rename from Diff/tests/syntax_test_git_diff_combined.patch rename to Git Formats/tests/syntax_test_git_diff_combined.patch index 069f543ceb..54ea02d3e4 100644 --- a/Diff/tests/syntax_test_git_diff_combined.patch +++ b/Git Formats/tests/syntax_test_git_diff_combined.patch @@ -1,4 +1,4 @@ -\ SYNTAX TEST "Packages/Diff/Git Diff.sublime-syntax" +\ SYNTAX TEST "Packages/Git Formats/Git Diff.sublime-syntax" diff --combined describe.c index fabadb8,cc95eb0..4866510 644 \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff From 472ec3a9fee0544876e8605510c990bb4a23084e Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 9 Dec 2024 12:48:35 -0500 Subject: [PATCH 072/127] [Diff] PHP embedding to v2 --- PHP/Embeddings/Diff (for PHP Interpolated).sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PHP/Embeddings/Diff (for PHP Interpolated).sublime-syntax b/PHP/Embeddings/Diff (for PHP Interpolated).sublime-syntax index 09d9adc406..6e089a3a1c 100644 --- a/PHP/Embeddings/Diff (for PHP Interpolated).sublime-syntax +++ b/PHP/Embeddings/Diff (for PHP Interpolated).sublime-syntax @@ -1,7 +1,7 @@ %YAML 1.2 --- scope: source.diff.interpolated.php -# version: 2 +version: 2 hidden: true extends: Packages/Diff/Diff.sublime-syntax From 92051bbac3c667c8d351e8e3be086c6fd84bd093 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 9 Dec 2024 23:28:50 -0500 Subject: [PATCH 073/127] [Diff] Move variables to the bottom --- Diff/Conflict.sublime-syntax | 7 ++++--- Diff/Diff.sublime-syntax | 26 +++++++++++++------------- Git Formats/Git Diff.sublime-syntax | 20 ++++++++++---------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax index df5f6f5bc2..231b3f3f4e 100644 --- a/Diff/Conflict.sublime-syntax +++ b/Diff/Conflict.sublime-syntax @@ -9,9 +9,6 @@ version: 2 file_extensions: - conflict -variables: - eol: (?:$\r?\n?) - contexts: pop-new-section: - match: ^(?=>{5,}|<{5,}|={5,}|\|{5,}) @@ -55,3 +52,7 @@ contexts: 2: entity.name.section.conflict pop: 1 - include: pop-new-section + + +variables: + eol: (?:$\r?\n?) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index ef4e01172f..7bbcbf8d3c 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -21,19 +21,6 @@ first_line_match: |- | \d+(,\d+)* [adc] \d+(,\d+)* $ ) -variables: - hash64: '[0-9a-fA-F]{64}' - hash40: '[0-9a-fA-F]{40}' - hash_full: (?:{{hash40}}|{{hash64}}) - git_first_line: |- - ^(?x: - From [ ] \w+@z [ ] - Thu [ ] Jan [ ]{2} 1 [ ] 00:00:00 [ ] 1970 # git-send-email - | From [ ] {{hash_full}} [ ] - Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch - ) - eol: (?:$\r?\n?) - contexts: ###[ PROTOTYPES ]############################################################## @@ -379,3 +366,16 @@ contexts: 4: punctuation.separator.date.diff 5: punctuation.separator.decimal.diff 6: storage.modifier.diff + +variables: + hash64: '[0-9a-fA-F]{64}' + hash40: '[0-9a-fA-F]{40}' + hash_full: (?:{{hash40}}|{{hash64}}) + git_first_line: |- + ^(?x: + From [ ] \w+@z [ ] + Thu [ ] Jan [ ]{2} 1 [ ] 00:00:00 [ ] 1970 # git-send-email + | From [ ] {{hash_full}} [ ] + Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch + ) + eol: (?:$\r?\n?) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 4fc2d9ac21..04afeecb0b 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -23,16 +23,6 @@ first_line_match: |- Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch ) -variables: - hash: '[0-9a-fA-F]{7,64}' - day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) - month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) - base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' - empty_line: ^(?=\r?\n) - scissors: (?:>8|8<) - # https://git-scm.com/docs/git-am#_discussion - next_diff_header: '(?=Index: |diff -)' - contexts: ###[ PROTOTYPES ]############################################################## @@ -509,3 +499,13 @@ contexts: separator-twodot: - match: \.\. scope: keyword.operator.logical.git + +variables: + hash: '[0-9a-fA-F]{7,64}' + day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) + month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) + base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' + empty_line: ^(?=\r?\n) + scissors: (?:>8|8<) + # https://git-scm.com/docs/git-am#_discussion + next_diff_header: '(?=Index: |diff -)' From 8e9fafc8a943d30d7d28759cad0272ae4a2a1cda Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 9 Dec 2024 23:44:17 -0500 Subject: [PATCH 074/127] [Diff] Move prototypes to the bottom --- Diff/Diff.sublime-syntax | 68 ++++++++++++++--------------- Git Formats/Git Diff.sublime-syntax | 22 +++++----- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 7bbcbf8d3c..d66642c143 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -22,40 +22,6 @@ first_line_match: |- ) contexts: - -###[ PROTOTYPES ]############################################################## - - pop-immediately: - - match: '' - pop: 1 - - pop-eol: - - match: '{{eol}}' - pop: 1 - - pop-before-eol: - - match: (?={{eol}}) - pop: 1 - - line-ranges: - - include: line-ranges-normal - - include: line-ranges-context - - include: line-ranges-unified - - deltas: - - include: deltas-normal - - include: deltas-context - - include: deltas-unified - - unified: - - include: headers-unified - - include: line-ranges-unified - - include: deltas-unified - - diff3: - - include: diff3-normal - - include: diff3-edit - main: - match: ^(?={{git_first_line}}) push: Packages/Git Formats/Git Diff.sublime-syntax#email-first-line @@ -367,6 +333,40 @@ contexts: 5: punctuation.separator.decimal.diff 6: storage.modifier.diff +###[ PROTOTYPES ]############################################################## + + pop-immediately: + - match: '' + pop: 1 + + pop-eol: + - match: '{{eol}}' + pop: 1 + + pop-before-eol: + - match: (?={{eol}}) + pop: 1 + + line-ranges: + - include: line-ranges-normal + - include: line-ranges-context + - include: line-ranges-unified + + deltas: + - include: deltas-normal + - include: deltas-context + - include: deltas-unified + + unified: + - include: headers-unified + - include: line-ranges-unified + - include: deltas-unified + + diff3: + - include: diff3-normal + - include: diff3-edit + + variables: hash64: '[0-9a-fA-F]{64}' hash40: '[0-9a-fA-F]{40}' diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 04afeecb0b..a5c227438f 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -24,17 +24,6 @@ first_line_match: |- ) contexts: - -###[ PROTOTYPES ]############################################################## - - pop-empty-line: - - match: '{{empty_line}}' - pop: 1 - - pop-before-diff-header: - - match: ^{{next_diff_header}} - pop: 1 - main: - match: ^(?={{git_first_line}}) push: email-first-line @@ -500,6 +489,17 @@ contexts: - match: \.\. scope: keyword.operator.logical.git +###[ PROTOTYPES ]############################################################## + + pop-empty-line: + - match: '{{empty_line}}' + pop: 1 + + pop-before-diff-header: + - match: ^{{next_diff_header}} + pop: 1 + + variables: hash: '[0-9a-fA-F]{7,64}' day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) From cd4c8da5edde31eeabf68e2e8ea1aae7d826c2cb Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 9 Dec 2024 23:44:33 -0500 Subject: [PATCH 075/127] [Diff] Add whitespace --- Diff/Conflict.sublime-syntax | 2 ++ Diff/Diff.sublime-syntax | 9 +++++++++ Git Formats/Git Diff.sublime-syntax | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax index 231b3f3f4e..65d0d7150f 100644 --- a/Diff/Conflict.sublime-syntax +++ b/Diff/Conflict.sublime-syntax @@ -26,6 +26,7 @@ contexts: - match: ^(?:<{5,}|>{5,}) scope: invalid.illegal.conflict - include: pop-new-section + # Index - match: ^(\|{5,})\s*(\S.*?)\s*{{eol}} captures: @@ -37,6 +38,7 @@ contexts: - match: ^(?:>{5,}|<{5,}) scope: invalid.illegal.conflict - include: pop-new-section + # New - match: ^(={5,})\s*{{eol}} captures: diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index d66642c143..4bc85de530 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -90,6 +90,7 @@ contexts: - include: dev-null - include: path-separators - include: date + maybe-headers-context-to-file: - match: ^(-{3})[ ](?!$) captures: @@ -97,6 +98,7 @@ contexts: push: headers-context-to-file - match: ^ pop: 1 + headers-context-to-file: - meta_scope: meta.diff.header.to-file meta.header.to-file.diff - include: pop-eol @@ -229,14 +231,17 @@ contexts: - meta_scope: markup.deleted.diff - include: pop-eol - include: trailing-whitespace + line-inserted: - meta_scope: markup.inserted.diff - include: pop-eol - include: trailing-whitespace + line-changed: - meta_scope: markup.changed.diff - include: pop-eol - include: trailing-whitespace + line-ignored: - meta_scope: comment.line.diff - include: pop-eol @@ -252,6 +257,7 @@ contexts: diff3-normal: - match: ^====[1-3]?{{eol}} scope: punctuation.section.block.diff + - match: ^([1-3])(:)(\d+(a)|\d+(?:(,)\d+)?(c)){{eol}} scope: meta.mapping.diff captures: @@ -277,6 +283,7 @@ contexts: push: - meta_content_scope: meta.block.diff markup.inserted.diff - include: diff3-edit-end + - match: ^(\d+)(d){{eol}} captures: 1: meta.diff.range.normal meta.range.normal.diff @@ -284,6 +291,7 @@ contexts: push: - meta_content_scope: meta.block.diff markup.deleted.diff - include: diff3-edit-end + - match: ^(\d+)(c){{eol}} captures: 1: meta.diff.range.normal meta.range.normal.diff @@ -322,6 +330,7 @@ contexts: 4: punctuation.separator.date.diff 5: punctuation.separator.decimal.diff 6: storage.modifier.diff + # 2002-02-21 23:30:50.442260588 -0800 - match: \b\d{4}(-)\d\d(-)\d\d \d?\d(:)\d\d(:)\d\d(?:(\.)\d+)?(?:[ ]([+-]?\d{4}))? scope: meta.date.diff meta.number.integer.decimal.diff constant.numeric.value.diff diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index a5c227438f..e80dea58b5 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -41,6 +41,7 @@ contexts: email-header: - meta_scope: meta.block.git-header.diff + # Person headers - match: |- ^(?x: @@ -60,6 +61,7 @@ contexts: - meta_scope: meta.mapping.diff - include: scope:text.git.mailmap - include: pop-before-eol + # Commit headers - match: ^(In-Reply-To|References)(:) captures: @@ -70,6 +72,7 @@ contexts: - match: '{{hash}}' scope: constant.other.hash.git - include: pop-before-eol + # Subject header - match: ^(Subject)(:) captures: @@ -96,6 +99,7 @@ contexts: 2: punctuation.separator.sequence.diff 3: meta.number.integer.decimal.diff constant.numeric.value.diff - include: pop-before-eol + # Date headers - match: ^((?:Author|Committer)?Date)(:) captures: @@ -121,6 +125,7 @@ contexts: 3: punctuation.separator.date.diff 4: storage.modifier.diff - include: pop-before-eol + # Other headers - match: ^\b([\w-]+)\b(:) captures: @@ -129,6 +134,7 @@ contexts: push: - meta_scope: meta.mapping.diff - include: pop-before-eol + # Go to Body - match: '{{empty_line}}' set: email-body @@ -263,6 +269,7 @@ contexts: - match: ^(?=@|GIT binary) set: diff-content - include: headers-unified + # old mode # new mode # deleted file mode @@ -272,12 +279,14 @@ contexts: - include: pop-before-eol - include: file-modes - include: separator-comma + # new file mode - match: ^(?=new file mode) push: - meta_content_scope: markup.inserted.diff - include: pop-before-eol - include: file-modes + # mode ,.. (for combined diff) - match: ^mode(?= [106475,.]+) scope: keyword.other.diff @@ -287,6 +296,7 @@ contexts: - include: separator-twodot # Combined mode can have multiple pre-commits - include: separator-comma + # copy from # copy to # rename from @@ -295,6 +305,7 @@ contexts: push: - include: pop-before-eol - include: path-separators + # similarity index # dissimilarity index - match: ^(?:dis)?similarity index @@ -305,6 +316,7 @@ contexts: captures: 1: constant.numeric.value.git 2: constant.numeric.suffix.git + # index .. - match: ^index(?= [0-9a-f,.]+) scope: keyword.other.diff From f7a8a3bf923b57d7881eb7a666ec16c92fcefbed Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 9 Dec 2024 23:47:15 -0500 Subject: [PATCH 076/127] [Diff] Categorize diff context separator --- Diff/Diff.sublime-syntax | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 4bc85de530..b8cef00159 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -71,13 +71,19 @@ contexts: 4: punctuation.definition.to-file.diff pop: 1 - include: pop-immediately - - match: ^(\*{15}|={67}){{eol}} + + # 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 # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Context headers-context: + - match: ^(\*{15}){{eol}} + scope: meta.separator.diff + captures: + 1: punctuation.separator.block.diff - match: ^(\*{3})[ ](?!$) captures: 1: punctuation.definition.from-file.diff From c339b0b4e8082cbbfafef781cedddc168d3697a9 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 00:27:00 -0500 Subject: [PATCH 077/127] [Diff] Prefer named contexts to push into --- Diff/Conflict.sublime-syntax | 56 +++--- Diff/Diff.sublime-syntax | 40 ++-- Git Formats/Git Diff.sublime-syntax | 283 +++++++++++++++------------- 3 files changed, 209 insertions(+), 170 deletions(-) diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax index 65d0d7150f..656d4a95ed 100644 --- a/Diff/Conflict.sublime-syntax +++ b/Diff/Conflict.sublime-syntax @@ -20,40 +20,46 @@ contexts: captures: 1: punctuation.section.block.begin.conflict 2: entity.name.section.conflict - push: - - meta_scope: meta.block.conflict - - meta_content_scope: markup.deleted.conflict - - match: ^(?:<{5,}|>{5,}) - scope: invalid.illegal.conflict - - include: pop-new-section - - # Index + push: deleted-lines + + # Base - match: ^(\|{5,})\s*(\S.*?)\s*{{eol}} captures: 1: punctuation.section.block.begin.conflict 2: entity.name.section.conflict - push: - - meta_scope: meta.block.conflict - - meta_content_scope: comment.block.conflict - - match: ^(?:>{5,}|<{5,}) - scope: invalid.illegal.conflict - - include: pop-new-section + push: base-lines # New - match: ^(={5,})\s*{{eol}} captures: 1: punctuation.section.block.begin.conflict - push: - - meta_scope: meta.block.conflict - - meta_content_scope: markup.inserted.conflict - - match: ^(?:={5,}|<{5,}|\|{5,}) - scope: invalid.illegal.conflict - - match: ^(>{5,})\s*(\S.*?)\s*{{eol}} - captures: - 1: punctuation.section.block.end.conflict - 2: entity.name.section.conflict - pop: 1 - - include: pop-new-section + push: new-lines + + deleted-lines: + - meta_scope: meta.block.conflict + - meta_content_scope: markup.deleted.conflict + - match: ^(?:<{5,}|>{5,}) + scope: invalid.illegal.conflict + - include: pop-new-section + + base-lines: + - meta_scope: meta.block.conflict + - meta_content_scope: comment.block.conflict + - match: ^(?:>{5,}|<{5,}) + scope: invalid.illegal.conflict + - include: pop-new-section + + new-lines: + - meta_scope: meta.block.conflict + - meta_content_scope: markup.inserted.conflict + - match: ^(?:={5,}|<{5,}|\|{5,}) + scope: invalid.illegal.conflict + - match: ^(>{5,})\s*(\S.*?)\s*{{eol}} + captures: + 1: punctuation.section.block.end.conflict + 2: entity.name.section.conflict + pop: 1 + - include: pop-new-section variables: diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index b8cef00159..7a670dcb23 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -117,21 +117,25 @@ contexts: - match: ^(-{3})[ ](?!$) captures: 1: punctuation.definition.from-file.diff - push: - - meta_scope: meta.diff.header.from-file meta.header.from-file.diff - - include: pop-eol - - include: dev-null - - include: path-separators - - include: date + push: headers-unified-from-file - match: ^(\+{3})[ ](?!$) captures: 1: punctuation.definition.to-file.diff - push: - - meta_scope: meta.diff.header.to-file meta.header.to-file.diff - - include: pop-eol - - include: dev-null - - include: path-separators - - include: date + push: headers-unified-to-file + + headers-unified-from-file: + - meta_scope: meta.diff.header.from-file meta.header.from-file.diff + - include: pop-eol + - include: dev-null + - include: path-separators + - include: date + + 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 ###[ RANGES ]################################################################## @@ -273,11 +277,13 @@ contexts: 4: support.function.diff 5: punctuation.separator.sequence.diff 6: support.function.diff - push: - - match: ^(?:\t| ) - push: line-changed - - match: ^ - pop: 1 + push: diff3-normal-change + + diff3-normal-change: + - match: ^(?:\t| ) + push: line-changed + - match: ^ + pop: 1 # This conflicts with non-diff3 Normal mode, so it's off by default # https://www.gnu.org/software/diffutils/manual/diffutils.html#Selecting-Which-Changes-to-Incorporate diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index e80dea58b5..bda35dfb98 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -57,88 +57,103 @@ contexts: captures: 1: keyword.other.diff 2: punctuation.separator.mapping.key-value.diff - push: - - meta_scope: meta.mapping.diff - - include: scope:text.git.mailmap - - include: pop-before-eol + push: email-header-person # Commit headers - match: ^(In-Reply-To|References)(:) captures: 1: keyword.other.diff 2: punctuation.separator.mapping.key-value.diff - push: - - meta_scope: meta.mapping.diff - - match: '{{hash}}' - scope: constant.other.hash.git - - include: pop-before-eol + push: email-header-commit # Subject header - match: ^(Subject)(:) captures: 1: keyword.other.diff 2: punctuation.separator.mapping.key-value.diff - push: - - meta_scope: meta.mapping.diff - - meta_content_scope: markup.heading.diff - - match: (\[)(?:(RFC) )?PATCH - captures: - 1: punctuation.definition.annotation.begin.diff - 2: storage.modifier.diff - push: - - meta_scope: variable.annotation.diff - - match: \] - scope: punctuation.definition.annotation.end.diff - pop: 1 - - match: \bv[0-9]+\b - scope: meta.annotation.patch-version.diff storage.modifier.diff - - match: ([0-9]+)(/)([0-9]+) - scope: meta.annotation.patch-sequence.diff - captures: - 1: meta.number.integer.decimal.diff constant.numeric.value.diff - 2: punctuation.separator.sequence.diff - 3: meta.number.integer.decimal.diff constant.numeric.value.diff - - include: pop-before-eol + push: email-header-subject-line # Date headers - match: ^((?:Author|Committer)?Date)(:) captures: 1: keyword.other.diff 2: punctuation.separator.mapping.key-value.diff - push: - - meta_scope: meta.mapping.diff - - match: |- - (?x: - {{day3}}(,) [ ] # Day of week - [0-3]?[0-9] [ ] # Day of month - {{month3}} [ ] # Month - [0-9]{4} [ ] # Year - [0-9]{2}(:) # Hour - [0-9]{2}(:) # Minute - [0-9]{2} # Second - (?:[ ]([+-][0-9]{4}))? # Optional UTC offset - ) - scope: meta.date.diff constant.numeric.value.diff - captures: - 1: punctuation.separator.date.diff - 2: punctuation.separator.date.diff - 3: punctuation.separator.date.diff - 4: storage.modifier.diff - - include: pop-before-eol + push: email-header-date # Other headers - match: ^\b([\w-]+)\b(:) captures: 1: keyword.other.diff 2: punctuation.separator.mapping.key-value.diff - push: - - meta_scope: meta.mapping.diff - - include: pop-before-eol + push: email-header-generic # Go to Body - match: '{{empty_line}}' set: email-body + email-header-person: + - meta_scope: meta.mapping.diff + - include: scope:text.git.mailmap + - include: pop-before-eol + + email-header-commit: + - meta_scope: meta.mapping.diff + - match: '{{hash}}' + scope: constant.other.hash.git + - include: pop-before-eol + + email-header-subject-line: + - meta_scope: meta.mapping.diff + - meta_content_scope: markup.heading.diff + - include: patch-annotation + - include: pop-before-eol + + patch-annotation: + - match: (\[)(?:(RFC) )?PATCH + captures: + 1: punctuation.definition.annotation.begin.diff + 2: storage.modifier.diff + push: patch-annotation-content + + patch-annotation-content: + - meta_scope: variable.annotation.diff + - match: \] + scope: punctuation.definition.annotation.end.diff + pop: 1 + - match: \bv[0-9]+\b + scope: meta.annotation.patch-version.diff storage.modifier.diff + - match: ([0-9]+)(/)([0-9]+) + scope: meta.annotation.patch-sequence.diff + captures: + 1: meta.number.integer.decimal.diff constant.numeric.value.diff + 2: punctuation.separator.sequence.diff + 3: meta.number.integer.decimal.diff constant.numeric.value.diff + + email-header-date: + - meta_scope: meta.mapping.diff + - match: |- + (?x: + {{day3}}(,) [ ] # Day of week + [0-3]?[0-9] [ ] # Day of month + {{month3}} [ ] # Month + [0-9]{4} [ ] # Year + [0-9]{2}(:) # Hour + [0-9]{2}(:) # Minute + [0-9]{2} # Second + (?:[ ]([+-][0-9]{4}))? # Optional UTC offset + ) + scope: meta.date.diff constant.numeric.value.diff + captures: + 1: punctuation.separator.date.diff + 2: punctuation.separator.date.diff + 3: punctuation.separator.date.diff + 4: storage.modifier.diff + - include: pop-before-eol + + email-header-generic: + - meta_scope: meta.mapping.diff + - include: pop-before-eol + email-body: - meta_content_scope: meta.block.git-body.diff # https://git-scm.com/docs/git-mailinfo#Documentation/git-mailinfo.txt---scissors @@ -169,71 +184,75 @@ contexts: stat: - include: pop-before-diff-header - match: ^ (?=([^|]+[ ]+)\|) - push: - - include: pop-before-eol - - match: (?=\S.+\|) - push: - - meta_content_scope: meta.toc-list.filename.diff entity.name.diff - - match: (?=[ ]+\|) - pop: 1 - - include: path-separators - - match: \.{3} - scope: keyword.operator.diff - - match: |- - (?x: - (\|)[ ]+ - (?: - (Bin)[ ]([0-9]+)[ ](->)[ ]([0-9]+)[ ](bytes) # Binary files - | ([0-9]+)[ ](\+*)(-*) # Text files - ) - ) - captures: - 1: punctuation.separator.sequence.diff - 2: storage.type.diff - 3: meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff - 4: keyword.operator.logical.diff - 5: meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff - 6: constant.numeric.suffix.diff - 7: meta.number.integer.decimal.diff constant.numeric.value.diff - 8: markup.inserted.diff - 9: markup.deleted.diff + push: stat-toc-line - match: ^(?= [0-9]+ file) - push: - - include: pop-eol - - match: '[0-9]+' - scope: meta.number.integer.decimal.diff constant.numeric.value.diff - - match: ',' - scope: punctuation.separator.sequence.diff - - match: insertions?(\()\+(\)) - scope: markup.inserted.diff - captures: - 1: punctuation.definition.diff - 2: punctuation.definition.diff - - match: deletions?(\()-(\)) - scope: markup.deleted.diff - captures: - 1: punctuation.definition.diff - 2: punctuation.definition.diff + push: stat-shortstat - match: ^ (?=create mode) - push: - - meta_content_scope: markup.inserted.diff - - include: pop-before-eol - - include: path-separators - - include: file-modes + push: stat-create-file - match: ^ (?=delete mode) - push: - - meta_content_scope: markup.deleted.diff - - include: pop-before-eol - - include: path-separators - - include: file-modes + push: stat-delete-file - match: '{{empty_line}}' set: diffs - file-modes: - - match: \b(?:100)?644\b - scope: meta.number.integer.octal.diff constant.numeric.value.diff - - match: \b(?:100)?755\b - scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff + stat-toc-line: + - include: pop-before-eol + - match: (?=\S.+\|) + push: stat-toc-filename + - match: |- + (?x: + (\|)[ ]+ + (?: + (Bin)[ ]([0-9]+)[ ](->)[ ]([0-9]+)[ ](bytes) # Binary files + | ([0-9]+)[ ](\+*)(-*) # Text files + ) + ) + captures: + 1: punctuation.separator.sequence.diff + 2: storage.type.diff + 3: meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff + 4: keyword.operator.logical.diff + 5: meta.number.integer.decimal.diff constant.numeric.value.diff markup.inserted.diff + 6: constant.numeric.suffix.diff + 7: meta.number.integer.decimal.diff constant.numeric.value.diff + 8: markup.inserted.diff + 9: markup.deleted.diff + + stat-toc-filename: + - meta_content_scope: meta.toc-list.filename.diff entity.name.diff + - match: (?=[ ]+\|) + pop: 1 + - include: path-separators + - match: \.{3} + scope: keyword.operator.diff + + stat-shortstat: + - include: pop-eol + - match: '[0-9]+' + scope: meta.number.integer.decimal.diff constant.numeric.value.diff + - match: ',' + scope: punctuation.separator.sequence.diff + - match: insertions?(\()\+(\)) + scope: markup.inserted.diff + captures: + 1: punctuation.definition.diff + 2: punctuation.definition.diff + - match: deletions?(\()-(\)) + scope: markup.deleted.diff + captures: + 1: punctuation.definition.diff + 2: punctuation.definition.diff + + stat-create-file: + - meta_content_scope: markup.inserted.diff + - include: pop-before-eol + - include: path-separators + - include: file-modes + + stat-delete-file: + - meta_content_scope: markup.deleted.diff + - include: pop-before-eol + - include: path-separators + - include: file-modes ###[ DIFF ]#################################################################### @@ -346,22 +365,24 @@ contexts: binary-deltas: - match: ^GIT binary patch scope: keyword.other.diff - push: - - match: ^(delta|literal) ([0-9]+) - captures: - 1: support.function.diff - 2: meta.number.integer.decimal.diff constant.numeric.value.diff - # Empty file - - match: ^(H)cmV\?d00001$ - scope: constant.language.null.diff - captures: - 1: punctuation.definition.string.begin.diff - - match: ^([A-Za-z]){{base85}}{1,66}$ - scope: meta.string.diff string.other.raw.diff - captures: - 1: punctuation.definition.string.begin.diff - - match: ^(?!delta|literal|$) - pop: 2 + push: binary-delta-content + + binary-delta-content: + - match: ^(delta|literal) ([0-9]+) + captures: + 1: support.function.diff + 2: meta.number.integer.decimal.diff constant.numeric.value.diff + # Empty file + - match: ^(H)cmV\?d00001$ + scope: constant.language.null.diff + captures: + 1: punctuation.definition.string.begin.diff + - match: ^([A-Za-z]){{base85}}{1,66}$ + scope: meta.string.diff string.other.raw.diff + captures: + 1: punctuation.definition.string.begin.diff + - match: ^(?!delta|literal|$) + pop: 2 # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt signature: @@ -501,6 +522,12 @@ contexts: - match: \.\. scope: keyword.operator.logical.git + file-modes: + - match: \b(?:100)?644\b + scope: meta.number.integer.octal.diff constant.numeric.value.diff + - match: \b(?:100)?755\b + scope: meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff + ###[ PROTOTYPES ]############################################################## pop-empty-line: From f05aae8ed142524acd044a6755131433581d2a43 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 14:14:00 -0500 Subject: [PATCH 078/127] [Diff] Assume carriage return is normalized away --- Diff/Conflict.sublime-syntax | 2 +- Diff/Diff.sublime-syntax | 2 +- Git Formats/Git Diff.sublime-syntax | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax index 656d4a95ed..5c995a44cb 100644 --- a/Diff/Conflict.sublime-syntax +++ b/Diff/Conflict.sublime-syntax @@ -63,4 +63,4 @@ contexts: variables: - eol: (?:$\r?\n?) + eol: (?:$\n?) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 7a670dcb23..6fe1516c70 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -399,4 +399,4 @@ variables: | From [ ] {{hash_full}} [ ] Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch ) - eol: (?:$\r?\n?) + eol: (?:$\n?) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index bda35dfb98..9309d190b4 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -159,7 +159,7 @@ contexts: # https://git-scm.com/docs/git-mailinfo#Documentation/git-mailinfo.txt---scissors - match: ^(?=--[ -]*{{scissors}}(?:{{scissors}}|[ -])*--\s*$) set: [email-header, scissors-line] - - match: ^(---)\r?\n + - match: ^(---)\n captures: 1: punctuation.section.block.diff set: [diffs, stat] @@ -544,7 +544,7 @@ variables: day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' - empty_line: ^(?=\r?\n) + empty_line: ^(?=\n) scissors: (?:>8|8<) # https://git-scm.com/docs/git-am#_discussion next_diff_header: '(?=Index: |diff -)' From 8650e78ea798ab9039dfb49b6e8390936af3026c Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 14:40:51 -0500 Subject: [PATCH 079/127] [Diff] ASCII-only in Base85 --- Git Formats/Git Diff.sublime-syntax | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 9309d190b4..1e17ff434f 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -368,19 +368,25 @@ contexts: push: binary-delta-content binary-delta-content: + # Binary type - match: ^(delta|literal) ([0-9]+) captures: 1: support.function.diff 2: meta.number.integer.decimal.diff constant.numeric.value.diff + # Empty file - match: ^(H)cmV\?d00001$ scope: constant.language.null.diff captures: 1: punctuation.definition.string.begin.diff + + # Base85-encoded binary data - match: ^([A-Za-z]){{base85}}{1,66}$ scope: meta.string.diff string.other.raw.diff captures: 1: punctuation.definition.string.begin.diff + + # Bail if anything else is encountered - match: ^(?!delta|literal|$) pop: 2 @@ -543,7 +549,7 @@ variables: hash: '[0-9a-fA-F]{7,64}' day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) - base85: '[\w!#$%&()*+\-;<=>?@^_`{|}~]' + base85: '[0-9a-zA-Z!#$%&()*+\-;<=>?@^_`{|}~]' empty_line: ^(?=\n) scissors: (?:>8|8<) # https://git-scm.com/docs/git-am#_discussion From 078f65c3f59b9a89a849e04e00099ec4aa9437b8 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 14:45:49 -0500 Subject: [PATCH 080/127] [Diff] Split email header context --- Git Formats/Git Diff.sublime-syntax | 82 ++++++++++++++++------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 1e17ff434f..88371d6aae 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -37,12 +37,22 @@ contexts: - match: '{{hash_full}}' scope: constant.other.hash.git - match: \n|$ - set: email-header + set: email-headers - email-header: + email-headers: - meta_scope: meta.block.git-header.diff - # Person headers + # Go to email body + - match: '{{empty_line}}' + set: email-body + + - include: email-header-person + - include: email-header-commit + - include: email-header-subject-line + - include: email-header-date + - include: email-header-generic + + email-header-person: - match: |- ^(?x: ( From | To | Author | Committer @@ -57,52 +67,34 @@ contexts: captures: 1: keyword.other.diff 2: punctuation.separator.mapping.key-value.diff - push: email-header-person - - # Commit headers - - match: ^(In-Reply-To|References)(:) - captures: - 1: keyword.other.diff - 2: punctuation.separator.mapping.key-value.diff - push: email-header-commit - - # Subject header - - match: ^(Subject)(:) - captures: - 1: keyword.other.diff - 2: punctuation.separator.mapping.key-value.diff - push: email-header-subject-line - - # Date headers - - match: ^((?:Author|Committer)?Date)(:) - captures: - 1: keyword.other.diff - 2: punctuation.separator.mapping.key-value.diff - push: email-header-date - - # Other headers - - match: ^\b([\w-]+)\b(:) - captures: - 1: keyword.other.diff - 2: punctuation.separator.mapping.key-value.diff - push: email-header-generic + push: email-header-person-body - # Go to Body - - match: '{{empty_line}}' - set: email-body - - email-header-person: + email-header-person-body: - meta_scope: meta.mapping.diff - include: scope:text.git.mailmap - include: pop-before-eol email-header-commit: + - match: ^(In-Reply-To|References)(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: email-header-commit-body + + email-header-commit-body: - meta_scope: meta.mapping.diff - match: '{{hash}}' scope: constant.other.hash.git - include: pop-before-eol email-header-subject-line: + - match: ^(Subject)(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: email-header-subject-line-body + + email-header-subject-line-body: - meta_scope: meta.mapping.diff - meta_content_scope: markup.heading.diff - include: patch-annotation @@ -130,6 +122,13 @@ contexts: 3: meta.number.integer.decimal.diff constant.numeric.value.diff email-header-date: + - match: ^((?:Author|Committer)?Date)(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: email-header-date-body + + email-header-date-body: - meta_scope: meta.mapping.diff - match: |- (?x: @@ -151,6 +150,13 @@ contexts: - include: pop-before-eol email-header-generic: + - match: ^\b([\w-]+)\b(:) + captures: + 1: keyword.other.diff + 2: punctuation.separator.mapping.key-value.diff + push: email-header-generic-body + + email-header-generic-body: - meta_scope: meta.mapping.diff - include: pop-before-eol @@ -158,7 +164,7 @@ contexts: - meta_content_scope: meta.block.git-body.diff # https://git-scm.com/docs/git-mailinfo#Documentation/git-mailinfo.txt---scissors - match: ^(?=--[ -]*{{scissors}}(?:{{scissors}}|[ -])*--\s*$) - set: [email-header, scissors-line] + set: [email-headers, scissors-line] - match: ^(---)\n captures: 1: punctuation.section.block.diff From 83a89f80066eb3fd172b31dea20ec7af0b00b121 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 14:47:32 -0500 Subject: [PATCH 081/127] [Diff] More explicit variable name for hash --- Diff/Diff.sublime-syntax | 8 ++++---- Git Formats/Git Diff.sublime-syntax | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 6fe1516c70..14f1325fad 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -389,14 +389,14 @@ contexts: variables: - hash64: '[0-9a-fA-F]{64}' - hash40: '[0-9a-fA-F]{40}' - hash_full: (?:{{hash40}}|{{hash64}}) + git_hash40: '[0-9a-fA-F]{40}' + git_hash64: '[0-9a-fA-F]{64}' + git_hash_full: (?:{{git_hash64}}|{{git_hash40}}) git_first_line: |- ^(?x: From [ ] \w+@z [ ] Thu [ ] Jan [ ]{2} 1 [ ] 00:00:00 [ ] 1970 # git-send-email - | From [ ] {{hash_full}} [ ] + | From [ ] {{git_hash_full}} [ ] Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch ) eol: (?:$\n?) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 88371d6aae..48b0b306e7 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -34,7 +34,7 @@ contexts: # https://git-scm.com/docs/git-format-patch#_description email-first-line: - meta_content_scope: comment.line.diff - - match: '{{hash_full}}' + - match: '{{git_hash_full}}' scope: constant.other.hash.git - match: \n|$ set: email-headers @@ -83,7 +83,7 @@ contexts: email-header-commit-body: - meta_scope: meta.mapping.diff - - match: '{{hash}}' + - match: '{{git_hash}}' scope: constant.other.hash.git - include: pop-before-eol @@ -519,11 +519,11 @@ contexts: scope: constant.language.null.git hash: - - match: '{{hash}}' + - match: '{{git_hash}}' scope: constant.other.hash.git hash-full-length: - - match: '{{hash_full}}' + - match: '{{git_hash_full}}' scope: constant.other.hash.git separator-comma: @@ -552,7 +552,7 @@ contexts: variables: - hash: '[0-9a-fA-F]{7,64}' + git_hash: '[0-9a-fA-F]{7,64}' day3: (?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) month3: (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) base85: '[0-9a-zA-Z!#$%&()*+\-;<=>?@^_`{|}~]' From a53b9fb92a923dc6d94c761b014923db01c18c4f Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 15:14:01 -0500 Subject: [PATCH 082/127] [Diff] More comments --- Git Formats/Git Diff.sublime-syntax | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 48b0b306e7..daf27af38a 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -27,6 +27,8 @@ contexts: main: - match: ^(?={{git_first_line}}) push: email-first-line + + # If you can't find the magic first line, just highlight diffs. - include: diffs ###[ EMAIL ]################################################################### @@ -312,6 +314,7 @@ contexts: - include: pop-before-eol - include: file-modes + # mode .. # mode ,.. (for combined diff) - match: ^mode(?= [106475,.]+) scope: keyword.other.diff @@ -398,7 +401,9 @@ contexts: # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt signature: - # This is the Git version unless otherwise configured + # This is the Git version unless otherwise configured. You will notice + # that once inside this context, you cannot leave. That seems to be how + # it works for these files. - match: ^(-- ){{eol}} captures: 1: meta.separator.diff punctuation.section.block.diff From 2f49b8068df34aa54f2ef2aefc4c4ffd08d607ae Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 15:17:43 -0500 Subject: [PATCH 083/127] [Diff] Add more variables to Conflict --- Diff/Conflict.sublime-syntax | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax index 5c995a44cb..f0c98a8343 100644 --- a/Diff/Conflict.sublime-syntax +++ b/Diff/Conflict.sublime-syntax @@ -11,26 +11,26 @@ file_extensions: contexts: pop-new-section: - - match: ^(?=>{5,}|<{5,}|={5,}|\|{5,}) + - match: ^(?={{any}}) pop: 1 main: # Old - - match: ^(<{5,})\s*(\S.*?)\s*{{eol}} + - match: ^({{begin}})\s*({{identifier}})\s*{{eol}} captures: 1: punctuation.section.block.begin.conflict 2: entity.name.section.conflict push: deleted-lines # Base - - match: ^(\|{5,})\s*(\S.*?)\s*{{eol}} + - match: ^({{base}})\s*({{identifier}})\s*{{eol}} captures: 1: punctuation.section.block.begin.conflict 2: entity.name.section.conflict push: base-lines # New - - match: ^(={5,})\s*{{eol}} + - match: ^({{split}})\s*{{eol}} captures: 1: punctuation.section.block.begin.conflict push: new-lines @@ -38,23 +38,23 @@ contexts: deleted-lines: - meta_scope: meta.block.conflict - meta_content_scope: markup.deleted.conflict - - match: ^(?:<{5,}|>{5,}) + - match: ^(?:{{begin}}|{{end}}) scope: invalid.illegal.conflict - include: pop-new-section base-lines: - meta_scope: meta.block.conflict - meta_content_scope: comment.block.conflict - - match: ^(?:>{5,}|<{5,}) + - match: ^(?:{{begin}}|{{end}}) scope: invalid.illegal.conflict - include: pop-new-section new-lines: - meta_scope: meta.block.conflict - meta_content_scope: markup.inserted.conflict - - match: ^(?:={5,}|<{5,}|\|{5,}) + - match: ^(?:{{begin}}|{{base}}|{{split}}) scope: invalid.illegal.conflict - - match: ^(>{5,})\s*(\S.*?)\s*{{eol}} + - match: ^({{end}})\s*({{identifier}})\s*{{eol}} captures: 1: punctuation.section.block.end.conflict 2: entity.name.section.conflict @@ -64,3 +64,11 @@ contexts: variables: eol: (?:$\n?) + + begin: <{5,} + end: '>{5,}' + split: ={5,} + base: \|{5,} + any: (?:{{begin}}|{{end}}|{{split}}|{{base}}) + + identifier: (?:\S.*?) From 6b8549087999ce3a78e3efd4fd7e3cfdf70d0437 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 15:34:55 -0500 Subject: [PATCH 084/127] [Diff] Conflict contexts --- Diff/Conflict.sublime-syntax | 74 ++++++++++++++---------- Diff/tests/syntax_test_conflict.conflict | 32 +++++++++- 2 files changed, 73 insertions(+), 33 deletions(-) diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax index f0c98a8343..9f29784a97 100644 --- a/Diff/Conflict.sublime-syntax +++ b/Diff/Conflict.sublime-syntax @@ -10,56 +10,70 @@ file_extensions: - conflict contexts: - pop-new-section: - - match: ^(?={{any}}) + main: + - include: conflicts + + conflicts: + - match: ^(?={{begin}}) + push: + - conflict + - conflict-marker-start + + conflict: + - meta_scope: meta.block.conflict + - match: '' pop: 1 - main: - # Old - - match: ^({{begin}})\s*({{identifier}})\s*{{eol}} + conflict-marker-start: + - match: '{{begin}}' + scope: punctuation.section.block.begin.conflict + - match: (?:({{identifier}})\s*)?{{eol}} captures: - 1: punctuation.section.block.begin.conflict - 2: entity.name.section.conflict - push: deleted-lines + 1: entity.name.section.conflict + set: deleted-lines - # Base - - match: ^({{base}})\s*({{identifier}})\s*{{eol}} + base-marker-start: + - match: '{{base}}' + scope: punctuation.section.block.conflict + - match: (?:({{identifier}})\s*)?{{eol}} captures: - 1: punctuation.section.block.begin.conflict - 2: entity.name.section.conflict - push: base-lines + 1: entity.name.section.conflict + set: base-lines - # New - - match: ^({{split}})\s*{{eol}} + split-marker-start: + - match: '{{split}}' + scope: punctuation.section.block.conflict + - match: (?:({{identifier}})\s*)?{{eol}} captures: - 1: punctuation.section.block.begin.conflict - push: new-lines + 1: entity.name.section.conflict + set: new-lines deleted-lines: - - meta_scope: meta.block.conflict - meta_content_scope: markup.deleted.conflict - - match: ^(?:{{begin}}|{{end}}) - scope: invalid.illegal.conflict - - include: pop-new-section + - match: ^(?={{base}}) + set: base-marker-start + - match: ^(?={{split}}) + set: split-marker-start + - include: invalid-conflict-marker base-lines: - - meta_scope: meta.block.conflict - meta_content_scope: comment.block.conflict - - match: ^(?:{{begin}}|{{end}}) - scope: invalid.illegal.conflict - - include: pop-new-section + - match: ^(?={{split}}) + set: split-marker-start + - include: invalid-conflict-marker new-lines: - - meta_scope: meta.block.conflict - meta_content_scope: markup.inserted.conflict - - match: ^(?:{{begin}}|{{base}}|{{split}}) - scope: invalid.illegal.conflict - - match: ^({{end}})\s*({{identifier}})\s*{{eol}} + - match: ^({{end}})\s*(?:({{identifier}})\s*)?{{eol}} captures: 1: punctuation.section.block.end.conflict 2: entity.name.section.conflict pop: 1 - - include: pop-new-section + - include: invalid-conflict-marker + + invalid-conflict-marker: + - match: ^(?:{{any}}) + scope: invalid.illegal.conflict variables: diff --git a/Diff/tests/syntax_test_conflict.conflict b/Diff/tests/syntax_test_conflict.conflict index e51f947935..90803c989b 100644 --- a/Diff/tests/syntax_test_conflict.conflict +++ b/Diff/tests/syntax_test_conflict.conflict @@ -10,7 +10,7 @@ https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 lines from A \^^^^^^^^^^^^ meta.block.conflict markup.deleted.conflict - meta.block meta.block ======= -\^^^^^^ meta.block.conflict punctuation.section.block.begin.conflict - meta.block meta.block - markup +\^^^^^^ meta.block.conflict punctuation.section.block.conflict - meta.block meta.block - markup lines from B \^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict >>>>>>> B @@ -26,14 +26,14 @@ context context lines from A ||||||| B \^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup -\^^^^^^ punctuation.section.block.begin.conflict +\^^^^^^ punctuation.section.block.conflict \ ^ - entity - punctuation \ ^ entity.name.section.conflict \ ^ - entity lines from B \^^^^^^^^^^^^ meta.block.conflict comment.block.conflict - meta.block meta.block - markup ======= -\^^^^^^ meta.block.conflict punctuation.section.block.begin.conflict - meta.block meta.block - markup +\^^^^^^ meta.block.conflict punctuation.section.block.conflict - meta.block meta.block - markup > \ <- meta.block.conflict markup.inserted.conflict - punctuation - invalid < @@ -100,3 +100,29 @@ open an issue ======= ask your question in IRC. >>>>>>> branch-a + + +\ https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging +#! /usr/bin/env ruby + +def hello +<<<<<<< ours + puts 'hola world' +||||||| base + puts 'hello world' +======= + puts 'hello mundo' +>>>>>>> theirs +end + +hello() + + +\ https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts +<<<<<<< HEAD:index.html + +======= + +>>>>>>> iss53:index.html From 193c171b9967057ca6161ef0b32319dbf795a5e8 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 15:54:34 -0500 Subject: [PATCH 085/127] [Diff] Nested conflicts --- Diff/Conflict.sublime-syntax | 2 ++ Diff/tests/syntax_test_conflict.conflict | 31 +++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax index 9f29784a97..8e0b2f9e8a 100644 --- a/Diff/Conflict.sublime-syntax +++ b/Diff/Conflict.sublime-syntax @@ -69,6 +69,8 @@ contexts: 1: punctuation.section.block.end.conflict 2: entity.name.section.conflict pop: 1 + # Nested conflicts in ReReRe + - include: conflicts - include: invalid-conflict-marker invalid-conflict-marker: diff --git a/Diff/tests/syntax_test_conflict.conflict b/Diff/tests/syntax_test_conflict.conflict index 90803c989b..cb1d2adbe6 100644 --- a/Diff/tests/syntax_test_conflict.conflict +++ b/Diff/tests/syntax_test_conflict.conflict @@ -38,7 +38,7 @@ lines from B \ <- meta.block.conflict markup.inserted.conflict - punctuation - invalid < \ <- meta.block.conflict markup.inserted.conflict - punctuation - invalid -<<<<< +||||| \^^^^ meta.block.conflict markup.inserted.conflict invalid.illegal.conflict lines from C \^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict @@ -126,3 +126,32 @@ hello() please contact us at support@github.com >>>>>>> iss53:index.html + + +\ https://git-scm.com/docs/rerere.html#_nested_conflicts +<<<<<<< HEAD +\^^^^^^^^^^^ meta.block.conflict +\^^^^^^ punctuation.section.block.begin.conflict +\ ^^^^ entity.name.section.conflict +111 +\^^ meta.block.conflict markup.deleted.conflict +======= +\^^^^^^ meta.block.conflict punctuation.section.block.conflict +<<<<<<< HEAD +\^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict meta.block.conflict +\^^^^^^ punctuation.section.block.begin.conflict +\ ^^^^ entity.name.section.conflict +333 +\^^ meta.block.conflict markup.inserted.conflict meta.block.conflict markup.deleted.conflict +======= +\^^^^^^ meta.block.conflict markup.inserted.conflict meta.block.conflict punctuation.section.block.conflict +222 +\^^ meta.block.conflict markup.inserted.conflict meta.block.conflict markup.inserted.conflict +>>>>>>> branch-2 +\^^^^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict meta.block.conflict +\^^^^^^ punctuation.section.block.end.conflict +\ ^^^^^^^^ entity.name.section.conflict +>>>>>>> branch-3~ +\^^^^^^^^^^^^^^^^ meta.block.conflict +\^^^^^^ punctuation.section.block.end.conflict +\ ^^^^^^^^^ entity.name.section.conflict From 97e8e48a989585219c74147ae0f01711617fce71 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 10 Dec 2024 16:05:43 -0500 Subject: [PATCH 086/127] [Diff] Conflict marker utility context --- Diff/Conflict.sublime-syntax | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax index 8e0b2f9e8a..740684f717 100644 --- a/Diff/Conflict.sublime-syntax +++ b/Diff/Conflict.sublime-syntax @@ -13,6 +13,13 @@ contexts: main: - include: conflicts + # Utility context for others to use + conflict-markers: + - match: ^({{any}})\s*({{identifier}})\s*{{eol}} + captures: + 1: punctuation.section.block.conflict + 2: entity.name.section.conflict + conflicts: - match: ^(?={{begin}}) push: From 36b33f1725df4c7731136e26599ebf0264d7ef4c Mon Sep 17 00:00:00 2001 From: Michael <2701605+michaelblyons@users.noreply.github.com> Date: Sun, 15 Dec 2024 09:11:57 -0500 Subject: [PATCH 087/127] [Diff] Named context for Git email quotes Co-authored-by: deathaxe --- Git Formats/Git Diff.sublime-syntax | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index daf27af38a..1bedef92ad 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -176,10 +176,12 @@ contexts: - include: Git Commit Message.sublime-syntax#commit-message - match: ^>+ scope: punctuation.definition.blockquote.git - push: - - meta_scope: markup.quote.git - - include: pop-eol - - include: Git Commit Message.sublime-syntax#commit-message + push: email-quote-body + + email-quote-body: + - meta_scope: markup.quote.git + - include: pop-eol + - include: Git Commit Message.sublime-syntax#commit-message scissors-line: - meta_scope: punctuation.section.block.git From 636739d92e0969e613bde01a9c8d80d3bddafb90 Mon Sep 17 00:00:00 2001 From: Michael <2701605+michaelblyons@users.noreply.github.com> Date: Sun, 15 Dec 2024 09:26:41 -0500 Subject: [PATCH 088/127] [Diff] Simplify date context Co-authored-by: deathaxe --- Git Formats/Git Diff.sublime-syntax | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 1bedef92ad..b1d4872901 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -133,16 +133,15 @@ contexts: email-header-date-body: - meta_scope: meta.mapping.diff - match: |- - (?x: - {{day3}}(,) [ ] # Day of week - [0-3]?[0-9] [ ] # Day of month - {{month3}} [ ] # Month - [0-9]{4} [ ] # Year - [0-9]{2}(:) # Hour - [0-9]{2}(:) # Minute - [0-9]{2} # Second - (?:[ ]([+-][0-9]{4}))? # Optional UTC offset - ) + (?x) + {{day3}}(,) [ ] # Day of week + [0-3]?[0-9] [ ] # Day of month + {{month3}} [ ] # Month + [0-9]{4} [ ] # Year + [0-9]{2} (:) # Hour + [0-9]{2} (:) # Minute + [0-9]{2} # Second + (?:[ ]([+-][0-9]{4}))? # Optional UTC offset scope: meta.date.diff constant.numeric.value.diff captures: 1: punctuation.separator.date.diff From afc7fc33f88a0a2bfd684291d4504c69b8130a35 Mon Sep 17 00:00:00 2001 From: Michael <2701605+michaelblyons@users.noreply.github.com> Date: Sun, 15 Dec 2024 10:15:43 -0500 Subject: [PATCH 089/127] [Diff] Named contexts for leading text body Co-authored-by: deathaxe --- Diff/Diff.sublime-syntax | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 14f1325fad..10e0310ec3 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -38,20 +38,24 @@ contexts: captures: 1: meta.mapping.key.diff keyword.other.diff 2: punctuation.separator.key-value.diff - push: - - 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 + push: index-body - match: ^(Prereq)(:)[ \t]* captures: 1: meta.mapping.key.diff keyword.other.diff 2: punctuation.separator.key-value.diff - push: - - meta_scope: meta.mapping.diff - - meta_content_scope: meta.mapping.value.diff string.unquoted.diff - - include: pop-eol - - include: path-separators + 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 ]################################################################# From ab04f94264a48e3b6ecd1f29f7e446d2bd9fe946 Mon Sep 17 00:00:00 2001 From: Michael <2701605+michaelblyons@users.noreply.github.com> Date: Sun, 15 Dec 2024 11:04:28 -0500 Subject: [PATCH 090/127] [Diff] Named context for header body Co-authored-by: deathaxe --- Diff/Diff.sublime-syntax | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 10e0310ec3..d271f1551a 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -66,15 +66,7 @@ contexts: scope: meta.diff.header.from-file meta.header.from-file.diff captures: 1: punctuation.definition.from-file.diff - push: - - match: '( (-) )(.* (={4})){{eol}}' - captures: - 1: meta.header.diff - 2: punctuation.separator.sequence.diff - 3: meta.diff.header.to-file meta.header.to-file.diff - 4: punctuation.definition.to-file.diff - pop: 1 - - include: pop-immediately + push: header-body # Still not sure what this is, but there's a preexisting unit test - match: ^(={67}){{eol}} @@ -82,6 +74,16 @@ contexts: captures: 1: punctuation.separator.block.diff + header-body: + - match: '( (-) )(.* (={4})){{eol}}' + captures: + 1: meta.header.diff + 2: punctuation.separator.sequence.diff + 3: meta.diff.header.to-file meta.header.to-file.diff + 4: punctuation.definition.to-file.diff + pop: 1 + - include: pop-immediately + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Context headers-context: - match: ^(\*{15}){{eol}} From b5c156aaf3cfc4963218cc0e8abae267fbb2362b Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 16 Dec 2024 14:43:55 -0500 Subject: [PATCH 091/127] [Diff] Remove some trailing whitespace --- Diff/Diff.sublime-syntax | 4 ++-- Git Formats/Git Diff.sublime-syntax | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index d271f1551a..fad70ced18 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -45,13 +45,13 @@ contexts: 2: punctuation.separator.key-value.diff push: prereq-body - index-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: + prereq-body: - meta_scope: meta.mapping.diff - meta_content_scope: meta.mapping.value.diff string.unquoted.diff - include: pop-eol diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index b1d4872901..f506dc7018 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -177,7 +177,7 @@ contexts: scope: punctuation.definition.blockquote.git push: email-quote-body - email-quote-body: + email-quote-body: - meta_scope: markup.quote.git - include: pop-eol - include: Git Commit Message.sublime-syntax#commit-message From df6b4d633edfbfd1aa2b54e48729d7ee0300fba7 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 16 Dec 2024 14:47:01 -0500 Subject: [PATCH 092/127] [Diff] Embed Git Diff instead of pushing Also match it only a single time. Co-Authored-By: @deathaxe --- Diff/Diff.sublime-syntax | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index fad70ced18..3e384b694f 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -24,7 +24,12 @@ first_line_match: |- contexts: main: - match: ^(?={{git_first_line}}) - push: Packages/Git Formats/Git Diff.sublime-syntax#email-first-line + embed: Packages/Git Formats/Git Diff.sublime-syntax#email-first-line + escape: (?!) + - match: ^ + push: diffs + + diffs: - include: leading-text - include: line-ranges - include: headers From fcff21af29548ed0132965c9f884e3a9185e45d3 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 16 Dec 2024 15:16:47 -0500 Subject: [PATCH 093/127] [Diff] Merge leading text with headers --- Diff/Diff.sublime-syntax | 66 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 3e384b694f..e9846b3598 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -30,56 +30,49 @@ contexts: push: 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 @@ -140,6 +133,7 @@ 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 @@ -147,6 +141,12 @@ contexts: - 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 ]################################################################## From 1f5f405fea397e4bf255d51a54bd3b9b105de1e6 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 16 Dec 2024 16:41:03 -0500 Subject: [PATCH 094/127] [Diff] Modify inheritable part of signature --- Git Formats/Git Diff.sublime-syntax | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index f506dc7018..cfc53adbfa 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -267,7 +267,6 @@ contexts: # https://git-scm.com/docs/diff-format#generate_patch_text_with_p diffs: - - include: signature - match: ^(diff) ((--)(?:git|combined|cc)) captures: 1: variable.function.diff @@ -275,6 +274,18 @@ contexts: 3: punctuation.definition.parameter.diff push: [diff-header, file-header-continue] + # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt + # This is the Git version unless otherwise configured. You will notice + # that once inside this context, you cannot leave. That seems to be how + # it works for these files. + - match: ^(-- ){{eol}} + captures: + 1: meta.separator.diff punctuation.section.block.diff + set: signature + + signature: + - meta_content_scope: comment.block.diff + file-header-continue: - meta_scope: meta.toc-list.git - include: pop-eol @@ -400,17 +411,6 @@ contexts: - match: ^(?!delta|literal|$) pop: 2 - # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt - signature: - # This is the Git version unless otherwise configured. You will notice - # that once inside this context, you cannot leave. That seems to be how - # it works for these files. - - match: ^(-- ){{eol}} - captures: - 1: meta.separator.diff punctuation.section.block.diff - set: - - meta_content_scope: comment.block.diff - ###[ COMBINED DIFF ]########################################################### # https://git-scm.com/docs/diff-format#_combined_diff_format From 53ae5aa1217ae4496d057e45bc01766b6c877359 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 16 Dec 2024 16:43:34 -0500 Subject: [PATCH 095/127] [Diff] Test Git-diff swap --- Diff/Diff.sublime-syntax | 2 ++ Diff/tests/syntax_test_diff.diff | 2 +- Diff/tests/syntax_test_switch_to_git.diff | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 Diff/tests/syntax_test_switch_to_git.diff diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index e9846b3598..39af9c0756 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -26,6 +26,8 @@ contexts: - match: ^(?={{git_first_line}}) embed: Packages/Git Formats/Git Diff.sublime-syntax#email-first-line escape: (?!) + # Hack for unit tests + - include: incomplete-line - match: ^ push: diffs diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 740f93e805..5fc51dc651 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -1,7 +1,7 @@ \ SYNTAX TEST "Packages/Diff/Diff.sublime-syntax" --- Path to Original File -\^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.from-file meta.header.from-file.diff +\^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.from-file meta.header.from-file.diff - source.diff.git \ <- punctuation.definition.from-file.diff \^^ punctuation.definition.from-file.diff diff --git a/Diff/tests/syntax_test_switch_to_git.diff b/Diff/tests/syntax_test_switch_to_git.diff new file mode 100644 index 0000000000..34296d957d --- /dev/null +++ b/Diff/tests/syntax_test_switch_to_git.diff @@ -0,0 +1,15 @@ +\ SYNTAX TEST "Packages/Git Formats/Git Diff.sublime-syntax" +From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001 +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.diff - source source +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git +From: Tony Luck +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.git-header.diff meta.mapping.diff - source source +\^^^ keyword.other.diff +\ ^ punctuation.separator.mapping.key-value.diff +\ ^^^^^^^^^ meta.reference.user.git +\ ^^^^^^^^^^^^^^^^^^^^^ meta.reference.email.git +\ ^ punctuation.definition.reference.email.begin.git +\ ^^^^^^^^^^^^^^^^^^^ entity.name.reference.email.git +\ ^ punctuation.separator.email.git +\ ^ punctuation.separator.domain.git +\ ^ punctuation.definition.reference.email.end.git From 2207f0a4d86d8ad221685bd7363c91092d1ecc77 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Tue, 17 Dec 2024 13:02:32 -0500 Subject: [PATCH 096/127] [Diff] Tests from SVN documentation --- Diff/tests/syntax_test_diff.diff | 67 ++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 5fc51dc651..d3e487e9ff 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -268,3 +268,70 @@ Diff3 Edit Format https://www.gnu.org/software/diffutils/manual/diffutils.html#S 8c so we may see their result. . + + +SVN sample https://svnbook.red-bean.com/en/1.7/svn-book.html#idm10685 +Index: deleted-file +\^^^^^^^^^^^^^^^^^^ meta.mapping.diff meta.diff.index meta.index.diff +\^^^^ meta.mapping.key.diff keyword.other.diff +\ ^ punctuation.separator.key-value.diff +\ ^^^^^^^^^^^^ meta.mapping.value.diff meta.toc-list.file-name.diff +=================================================================== +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff +--- deleted-file (revision 3) +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.from-file meta.header.from-file.diff +\^^ punctuation.definition.from-file.diff +\ ^^^^^^^^^^^^ comment.block.diff ++++ deleted-file (working copy) +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.to-file meta.header.to-file.diff +\^^ punctuation.definition.to-file.diff +\ ^^^^^^^^^^^^^^ comment.block.diff +@@ -1 +0,0 @@ +\^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff meta.toc-list.hunk.diff +\^ punctuation.definition.range.begin.diff +\ ^ support.function.diff +\ ^ support.function.diff +\ ^ punctuation.separator.sequence.diff +\ ^^ punctuation.definition.range.end.diff +-This file will be deleted. +\^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff +Index: changed-file +\^^^^^^^^^^^^^^^^^^ meta.mapping.diff meta.diff.index meta.index.diff +\^^^^ meta.mapping.key.diff keyword.other.diff +\ ^ punctuation.separator.key-value.diff +\ ^^^^^^^^^^^^ meta.mapping.value.diff meta.toc-list.file-name.diff +=================================================================== +--- changed-file (revision 4) ++++ changed-file (working copy) +@@ -1,6 +1,6 @@ + The letters in a line of text + Could make your day much better. + But expanded into paragraphs, +-I'd tell of kangaroos and calves +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff ++I'd tell of monkeys and giraffes +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff + Until you were all smiles and laughs + From my letter made of letters. + +Property changes on: changed-file +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.diff meta.diff.index meta.index.diff +\^^^^^^^^^^^^^^^^^^ meta.mapping.key.diff keyword.other.diff +\ ^ punctuation.separator.key-value.diff +\ ^^^^^^^^^^^^ meta.mapping.value.diff meta.toc-list.file-name.diff +___________________________________________________________________ +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff +Added: propname +\^^^^^^^^^^^^^^ meta.mapping.diff meta.diff.index meta.index.diff +\^^^^ meta.mapping.key.diff keyword.other.diff +\ ^ punctuation.separator.key-value.diff +\ ^^^^^^^^ meta.mapping.value.diff meta.toc-list.file-name.diff +## -0,0 +1 ## ++propvalue +\^^^^^^^^^ markup.inserted.diff +Index: added-file +=================================================================== +--- added-file (revision 0) ++++ added-file (working copy) +@@ -0,0 +1 @@ ++This is an added file. From fd7bfeeca0e92bbd10099e6fa07b1bc807fb91cf Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Mon, 16 Dec 2024 15:37:56 -0500 Subject: [PATCH 097/127] [Diff] Split unified diff into a common base to avoid a lot of unused contexts --- Diff/Diff (Unified).sublime-syntax | 309 ++++++++++++++++++++++++++++ Diff/Diff.sublime-syntax | 213 ++----------------- Git Formats/Git Diff.sublime-syntax | 2 +- 3 files changed, 325 insertions(+), 199 deletions(-) create mode 100644 Diff/Diff (Unified).sublime-syntax diff --git a/Diff/Diff (Unified).sublime-syntax b/Diff/Diff (Unified).sublime-syntax new file mode 100644 index 0000000000..47411ff3a2 --- /dev/null +++ b/Diff/Diff (Unified).sublime-syntax @@ -0,0 +1,309 @@ +%YAML 1.2 +--- +# https://www.sublimetext.com/docs/syntax.html +# https://www.gnu.org/software/diffutils/manual/diffutils.html +name: Unified Diff +scope: source.diff.unified +version: 2 +hidden: true + +file_extensions: [] + +contexts: + main: + - match: ^(?={{git_first_line}}) + embed: Packages/Git Formats/Git Diff.sublime-syntax#email-first-line + escape: (?!) + # Hack for unit tests + - include: incomplete-line + - match: ^ + push: diffs + + diffs: + - include: line-ranges + - include: headers + - include: deltas + +###[ HEADERS ]################################################################# + + headers: + - include: headers-context + - include: headers-unified + + # 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: 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: header-index-file-body + + # 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-4equals-body + + 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-4equals-body: + - match: '( (-) )(.* (={4})){{eol}}' + captures: + 1: meta.header.diff + 2: punctuation.separator.sequence.diff + 3: meta.diff.header.to-file meta.header.to-file.diff + 4: punctuation.definition.to-file.diff + pop: 1 + - include: pop-immediately + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Context + headers-context: + - match: ^(\*{15}){{eol}} + scope: meta.separator.diff + captures: + 1: punctuation.separator.block.diff + - match: ^(\*{3})[ ](?!$) + captures: + 1: punctuation.definition.from-file.diff + push: headers-context-from-file + + headers-context-from-file: + - meta_scope: meta.diff.header.from-file meta.header.from-file.diff + - match: '{{eol}}' + set: maybe-headers-context-to-file + - include: dev-null + - include: path-separators + - include: date + + maybe-headers-context-to-file: + - match: ^(-{3})[ ](?!$) + captures: + 1: punctuation.definition.to-file.diff + push: headers-context-to-file + - match: ^ + pop: 1 + + headers-context-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 + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified + headers-unified: + - match: ^(-{3})[ ](?!$) + captures: + 1: punctuation.definition.from-file.diff + push: headers-unified-from-file + - match: ^(\+{3})[ ](?!$) + captures: + 1: punctuation.definition.to-file.diff + push: headers-unified-to-file + + headers-unified-from-file: + - meta_scope: meta.diff.header.from-file meta.header.from-file.diff + - include: pop-eol + - 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 ]################################################################## + + line-ranges: + - include: line-ranges-unified + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks + line-ranges-normal: + - match: ^-{3}{{eol}} + scope: meta.separator.diff punctuation.separator.block.diff + - match: ^\d+(?:(,)\d+)*(a|d|c)\d+(?:(,)\d+)*{{eol}} + scope: meta.diff.range.normal meta.range.normal.diff + captures: + 1: punctuation.separator.sequence.diff + 2: support.function.diff + 3: punctuation.separator.sequence.diff + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context + line-ranges-context: + - match: ^(-){3}(?= .+ -{4}{{eol}}) + scope: punctuation.definition.range.begin.diff + push: inside-line-ranges-context + - match: ^(\*){3}(?= .+ \*{4}{{eol}}) + scope: punctuation.definition.range.begin.diff + push: inside-line-ranges-context + + inside-line-ranges-context: + - meta_scope: meta.diff.range.context meta.range.context.diff meta.toc-list.hunk.diff + - include: pop-eol + - match: \1{4} + scope: punctuation.definition.range.end.diff + pop: 1 + - include: line-range-span + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified + line-ranges-unified: + - match: ^(@@)(?=[^@\n]+@@(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [hunk-name, inside-line-ranges-unified] + + inside-line-ranges-unified: + - meta_scope: meta.diff.range.unified meta.range.unified.diff meta.toc-list.hunk.diff + - include: pop-eol + - match: \1 + scope: punctuation.definition.range.end.diff + pop: 1 + - include: line-range-span + - match: '[+-](?=\d)' + scope: support.function.diff + + hunk-name: + - include: pop-eol + - match: '[ \t]+' + scope: meta.toc-list.hunk.diff + - match: \S.+?(?=\s*{{eol}}) + scope: meta.toc-list.hunk.diff entity.name.section.diff + + line-range-span: + - match: \d+(?:(,)\d+)? + captures: + 1: punctuation.separator.sequence.diff + +###[ DELTAS ]################################################################## + + deltas: + - include: deltas-unified + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified + deltas-unified: + - match: ^\+ + scope: punctuation.definition.inserted.diff + push: line-inserted + - match: ^- + scope: punctuation.definition.deleted.diff + push: line-deleted + - include: incomplete-line + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Incomplete-Lines + incomplete-line: + - match: ^[\\/] + scope: punctuation.definition.comment.begin.diff + push: line-ignored + + line-deleted: + - meta_scope: markup.deleted.diff + - include: pop-eol + - include: trailing-whitespace + + line-inserted: + - meta_scope: markup.inserted.diff + - include: pop-eol + - include: trailing-whitespace + + line-changed: + - meta_scope: markup.changed.diff + - include: pop-eol + - include: trailing-whitespace + + line-ignored: + - meta_scope: comment.line.diff + - include: pop-eol + - include: trailing-whitespace + + trailing-whitespace: + - match: '[ \t]*(?=$)' + scope: meta.whitespace.trailing.diff + +###[ COMPONENTS ]############################################################## + + dev-null: + - match: /dev/null\b + scope: constant.language.null.diff + + path-separators: + - match: /|\\ + scope: punctuation.separator.sequence.diff + - match: \B\.\.(?=/|\\) + scope: constant.other.path.parent.diff + - match: \B\.(?=/|\\) + scope: constant.other.path.self.diff + + date: + # 1970-01-01 00:00:00 +0000 + - match: \b1970(-)01(-)01 0?0(:)00(:)00(?:(\.)0+)?(?:[ ]([+-]?0000|UTC))? + scope: meta.date.diff constant.language.null.diff + captures: + 1: punctuation.separator.date.diff + 2: punctuation.separator.date.diff + 3: punctuation.separator.date.diff + 4: punctuation.separator.date.diff + 5: punctuation.separator.decimal.diff + 6: storage.modifier.diff + + # 2002-02-21 23:30:50.442260588 -0800 + - match: \b\d{4}(-)\d\d(-)\d\d \d?\d(:)\d\d(:)\d\d(?:(\.)\d+)?(?:[ ]([+-]?\d{4}))? + scope: meta.date.diff meta.number.integer.decimal.diff constant.numeric.value.diff + captures: + 1: punctuation.separator.date.diff + 2: punctuation.separator.date.diff + 3: punctuation.separator.date.diff + 4: punctuation.separator.date.diff + 5: punctuation.separator.decimal.diff + 6: storage.modifier.diff + +###[ PROTOTYPES ]############################################################## + + pop-immediately: + - match: '' + pop: 1 + + pop-eol: + - match: '{{eol}}' + pop: 1 + + pop-before-eol: + - match: (?={{eol}}) + pop: 1 + +variables: + git_hash40: '[0-9a-fA-F]{40}' + git_hash64: '[0-9a-fA-F]{64}' + git_hash_full: (?:{{git_hash64}}|{{git_hash40}}) + git_first_line: |- + ^(?x: + From [ ] \w+@z [ ] + Thu [ ] Jan [ ]{2} 1 [ ] 00:00:00 [ ] 1970 # git-send-email + | From [ ] {{git_hash_full}} [ ] + Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch + ) + eol: (?:$\n?) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 39af9c0756..bd35082600 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -5,6 +5,7 @@ name: Diff scope: source.diff version: 2 +extends: Diff (Unified).sublime-syntax file_extensions: - diff @@ -22,26 +23,18 @@ first_line_match: |- ) contexts: - main: - - match: ^(?={{git_first_line}}) - embed: Packages/Git Formats/Git Diff.sublime-syntax#email-first-line - escape: (?!) - # Hack for unit tests - - include: incomplete-line - - match: ^ - push: diffs diffs: - - include: line-ranges - - include: headers - - include: deltas + - meta_append: true - include: diff3-normal + # Diff3 Edit conflicts with non-diff3 Normal mode, so it's off by default. + # With branching, it could probably be enabled, too. ###[ HEADERS ]################################################################# headers: + - meta_prepend: true - include: headers-context - - include: headers-unified # https://svnbook.red-bean.com/en/1.7/svn-book.html#svn.ref.svn.c.patch - match: ^(={67}|={78}|_{67}){{eol}} @@ -118,40 +111,13 @@ contexts: - include: path-separators - include: date - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified - headers-unified: - - match: ^(-{3})[ ](?!$) - captures: - 1: punctuation.definition.from-file.diff - push: headers-unified-from-file - - match: ^(\+{3})[ ](?!$) - captures: - 1: punctuation.definition.to-file.diff - push: headers-unified-to-file - - headers-unified-from-file: - - meta_scope: meta.diff.header.from-file meta.header.from-file.diff - - include: pop-eol - - 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 ]################################################################## + line-ranges: + - meta_prepend: true + - include: line-ranges-normal + - include: line-ranges-context + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks line-ranges-normal: - match: ^-{3}{{eol}} @@ -180,37 +146,13 @@ contexts: pop: 1 - include: line-range-span - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified - line-ranges-unified: - - match: ^(@@)(?=[^@\n]+@@(?:\s|$)) - captures: - 1: punctuation.definition.range.begin.diff - push: [hunk-name, inside-line-ranges-unified] - - inside-line-ranges-unified: - - meta_scope: meta.diff.range.unified meta.range.unified.diff meta.toc-list.hunk.diff - - include: pop-eol - - match: \1 - scope: punctuation.definition.range.end.diff - pop: 1 - - include: line-range-span - - match: '[+-](?=\d)' - scope: support.function.diff - - hunk-name: - - include: pop-eol - - match: '[ \t]+' - scope: meta.toc-list.hunk.diff - - match: \S.+?(?=\s*{{eol}}) - scope: meta.toc-list.hunk.diff entity.name.section.diff - - line-range-span: - - match: \d+(?:(,)\d+)? - captures: - 1: punctuation.separator.sequence.diff - ###[ DELTAS ]################################################################## + deltas: + - meta_prepend: true + - include: deltas-normal + - include: deltas-context + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal deltas-normal: - match: ^> ? @@ -234,46 +176,6 @@ contexts: push: line-changed - include: incomplete-line - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified - deltas-unified: - - match: ^\+ - scope: punctuation.definition.inserted.diff - push: line-inserted - - match: ^- - scope: punctuation.definition.deleted.diff - push: line-deleted - - include: incomplete-line - - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Incomplete-Lines - incomplete-line: - - match: ^[\\/] - scope: punctuation.definition.comment.begin.diff - push: line-ignored - - line-deleted: - - meta_scope: markup.deleted.diff - - include: pop-eol - - include: trailing-whitespace - - line-inserted: - - meta_scope: markup.inserted.diff - - include: pop-eol - - include: trailing-whitespace - - line-changed: - - meta_scope: markup.changed.diff - - include: pop-eol - - include: trailing-whitespace - - line-ignored: - - meta_scope: comment.line.diff - - include: pop-eol - - include: trailing-whitespace - - trailing-whitespace: - - match: '[ \t]*(?=$)' - scope: meta.whitespace.trailing.diff - ###[ DIFF3 ]################################################################### # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-diff3-Normal @@ -298,7 +200,6 @@ contexts: - match: ^ pop: 1 - # This conflicts with non-diff3 Normal mode, so it's off by default # https://www.gnu.org/software/diffutils/manual/diffutils.html#Selecting-Which-Changes-to-Incorporate diff3-edit: - match: ^(\d+)(a){{eol}} @@ -329,87 +230,3 @@ contexts: - match: ^\.$ scope: punctuation.section.block.end.diff pop: 1 - -###[ COMPONENTS ]############################################################## - - dev-null: - - match: /dev/null\b - scope: constant.language.null.diff - - path-separators: - - match: /|\\ - scope: punctuation.separator.sequence.diff - - match: \B\.\.(?=/|\\) - scope: constant.other.path.parent.diff - - match: \B\.(?=/|\\) - scope: constant.other.path.self.diff - - date: - # 1970-01-01 00:00:00 +0000 - - match: \b1970(-)01(-)01 0?0(:)00(:)00(?:(\.)0+)?(?:[ ]([+-]?0000|UTC))? - scope: meta.date.diff constant.language.null.diff - captures: - 1: punctuation.separator.date.diff - 2: punctuation.separator.date.diff - 3: punctuation.separator.date.diff - 4: punctuation.separator.date.diff - 5: punctuation.separator.decimal.diff - 6: storage.modifier.diff - - # 2002-02-21 23:30:50.442260588 -0800 - - match: \b\d{4}(-)\d\d(-)\d\d \d?\d(:)\d\d(:)\d\d(?:(\.)\d+)?(?:[ ]([+-]?\d{4}))? - scope: meta.date.diff meta.number.integer.decimal.diff constant.numeric.value.diff - captures: - 1: punctuation.separator.date.diff - 2: punctuation.separator.date.diff - 3: punctuation.separator.date.diff - 4: punctuation.separator.date.diff - 5: punctuation.separator.decimal.diff - 6: storage.modifier.diff - -###[ PROTOTYPES ]############################################################## - - pop-immediately: - - match: '' - pop: 1 - - pop-eol: - - match: '{{eol}}' - pop: 1 - - pop-before-eol: - - match: (?={{eol}}) - pop: 1 - - line-ranges: - - include: line-ranges-normal - - include: line-ranges-context - - include: line-ranges-unified - - deltas: - - include: deltas-normal - - include: deltas-context - - include: deltas-unified - - unified: - - include: headers-unified - - include: line-ranges-unified - - include: deltas-unified - - diff3: - - include: diff3-normal - - include: diff3-edit - - -variables: - git_hash40: '[0-9a-fA-F]{40}' - git_hash64: '[0-9a-fA-F]{64}' - git_hash_full: (?:{{git_hash64}}|{{git_hash40}}) - git_first_line: |- - ^(?x: - From [ ] \w+@z [ ] - Thu [ ] Jan [ ]{2} 1 [ ] 00:00:00 [ ] 1970 # git-send-email - | From [ ] {{git_hash_full}} [ ] - Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch - ) - eol: (?:$\n?) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index cfc53adbfa..8ea919fdb7 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -6,7 +6,7 @@ name: Git Diff scope: source.diff.git version: 2 -extends: Packages/Diff/Diff.sublime-syntax +extends: Packages/Diff/Diff (Unified).sublime-syntax file_extensions: - diff.eml From b1f984fccfb7bdf4b352ed7f952d7c2c6fe41c0d Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 17:24:24 +0100 Subject: [PATCH 098/127] [Diff] Rename diff header related contexts ... so all Diff syntaxes share same `diff-header` name so they replace or extend each other properly. Before `headers` was unused in `Git Diff`. --- Diff/Diff (Unified).sublime-syntax | 46 ++++++++++++++--------------- Diff/Diff.sublime-syntax | 26 ++++++++-------- Git Formats/Git Diff.sublime-syntax | 2 +- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Diff/Diff (Unified).sublime-syntax b/Diff/Diff (Unified).sublime-syntax index 47411ff3a2..e446162fec 100644 --- a/Diff/Diff (Unified).sublime-syntax +++ b/Diff/Diff (Unified).sublime-syntax @@ -21,14 +21,14 @@ contexts: diffs: - include: line-ranges - - include: headers + - include: diff-header - include: deltas ###[ HEADERS ]################################################################# - headers: - - include: headers-context - - include: headers-unified + diff-header: + - include: diff-header-context + - include: diff-header-unified # https://svnbook.red-bean.com/en/1.7/svn-book.html#svn.ref.svn.c.patch - match: ^(={67}|={78}|_{67}){{eol}} @@ -45,7 +45,7 @@ contexts: captures: 1: meta.mapping.key.diff keyword.other.diff 2: punctuation.separator.key-value.diff - push: header-index-file-body + push: diff-header-index-file-body # Can't find documentation for these "="-formatted headers, but there # are preexisting unit tests. @@ -53,15 +53,15 @@ contexts: scope: meta.diff.header.from-file meta.header.from-file.diff captures: 1: punctuation.definition.from-file.diff - push: header-4equals-body + push: diff-header-4equals-body - header-index-file-body: + 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-4equals-body: + diff-header-4equals-body: - match: '( (-) )(.* (={4})){{eol}}' captures: 1: meta.header.diff @@ -72,7 +72,7 @@ contexts: - include: pop-immediately # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Context - headers-context: + diff-header-context: - match: ^(\*{15}){{eol}} scope: meta.separator.diff captures: @@ -80,25 +80,25 @@ contexts: - match: ^(\*{3})[ ](?!$) captures: 1: punctuation.definition.from-file.diff - push: headers-context-from-file + push: diff-header-context-from-file - headers-context-from-file: + diff-header-context-from-file: - meta_scope: meta.diff.header.from-file meta.header.from-file.diff - match: '{{eol}}' - set: maybe-headers-context-to-file + set: maybe-diff-header-context-to-file - include: dev-null - include: path-separators - include: date - maybe-headers-context-to-file: + maybe-diff-header-context-to-file: - match: ^(-{3})[ ](?!$) captures: 1: punctuation.definition.to-file.diff - push: headers-context-to-file + push: diff-header-context-to-file - match: ^ pop: 1 - headers-context-to-file: + diff-header-context-to-file: - meta_scope: meta.diff.header.to-file meta.header.to-file.diff - include: pop-eol - include: dev-null @@ -106,33 +106,33 @@ contexts: - include: date # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified - headers-unified: + diff-header-unified: - match: ^(-{3})[ ](?!$) captures: 1: punctuation.definition.from-file.diff - push: headers-unified-from-file + push: diff-header-unified-from-file - match: ^(\+{3})[ ](?!$) captures: 1: punctuation.definition.to-file.diff - push: headers-unified-to-file + push: diff-header-unified-to-file - headers-unified-from-file: + diff-header-unified-from-file: - meta_scope: meta.diff.header.from-file meta.header.from-file.diff - include: pop-eol - include: dev-null - include: path-separators - include: date - - include: headers-unified-file-comment + - include: diff-header-unified-file-comment - headers-unified-to-file: + diff-header-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 + - include: diff-header-unified-file-comment - headers-unified-file-comment: + diff-header-unified-file-comment: - match: \s+(\(.+\))(?=$) captures: 1: comment.block.diff diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index bd35082600..e464c75a24 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -32,9 +32,9 @@ contexts: ###[ HEADERS ]################################################################# - headers: + diff-header: - meta_prepend: true - - include: headers-context + - include: diff-header-context # https://svnbook.red-bean.com/en/1.7/svn-book.html#svn.ref.svn.c.patch - match: ^(={67}|={78}|_{67}){{eol}} @@ -51,7 +51,7 @@ contexts: captures: 1: meta.mapping.key.diff keyword.other.diff 2: punctuation.separator.key-value.diff - push: header-index-file-body + push: diff-header-index-file-body # Can't find documentation for these "="-formatted headers, but there # are preexisting unit tests. @@ -59,15 +59,15 @@ contexts: scope: meta.diff.header.from-file meta.header.from-file.diff captures: 1: punctuation.definition.from-file.diff - push: header-4equals-body + push: diff-header-4equals-body - header-index-file-body: + 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-4equals-body: + diff-header-4equals-body: - match: '( (-) )(.* (={4})){{eol}}' captures: 1: meta.header.diff @@ -78,7 +78,7 @@ contexts: - include: pop-immediately # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Context - headers-context: + diff-header-context: - match: ^(\*{15}){{eol}} scope: meta.separator.diff captures: @@ -86,25 +86,25 @@ contexts: - match: ^(\*{3})[ ](?!$) captures: 1: punctuation.definition.from-file.diff - push: headers-context-from-file + push: diff-header-context-from-file - headers-context-from-file: + diff-header-context-from-file: - meta_scope: meta.diff.header.from-file meta.header.from-file.diff - match: '{{eol}}' - set: maybe-headers-context-to-file + set: maybe-diff-header-context-to-file - include: dev-null - include: path-separators - include: date - maybe-headers-context-to-file: + maybe-diff-header-context-to-file: - match: ^(-{3})[ ](?!$) captures: 1: punctuation.definition.to-file.diff - push: headers-context-to-file + push: diff-header-context-to-file - match: ^ pop: 1 - headers-context-to-file: + diff-header-context-to-file: - meta_scope: meta.diff.header.to-file meta.header.to-file.diff - include: pop-eol - include: dev-null diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 8ea919fdb7..0faed649a2 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -307,7 +307,7 @@ contexts: # Detect & switch context to changed content - match: ^(?=@|GIT binary) set: diff-content - - include: headers-unified + - include: diff-header-unified # old mode # new mode From 2f1ddd1bd8ba87fd895308a7c0ad1f30e99ee099 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 17:29:42 +0100 Subject: [PATCH 099/127] [Diff] Remove redundant diff header implementations This commit... 1. removes GNU diff specific patterns and contexts from base syntax. 2. extends Git Diff's diff-header from base syntax. This commit assumes removed contexts to be uniquely required for GNU Diff, as they are overridden/unused in Git Diffs. --- Diff/Diff (Unified).sublime-syntax | 104 ---------------------------- Diff/Diff.sublime-syntax | 2 +- Git Formats/Git Diff.sublime-syntax | 2 +- 3 files changed, 2 insertions(+), 106 deletions(-) diff --git a/Diff/Diff (Unified).sublime-syntax b/Diff/Diff (Unified).sublime-syntax index e446162fec..cb03643fd6 100644 --- a/Diff/Diff (Unified).sublime-syntax +++ b/Diff/Diff (Unified).sublime-syntax @@ -27,84 +27,8 @@ contexts: ###[ HEADERS ]################################################################# diff-header: - - include: diff-header-context - include: diff-header-unified - # 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: 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: diff-header-index-file-body - - # 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: diff-header-4equals-body - - 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 - - diff-header-4equals-body: - - match: '( (-) )(.* (={4})){{eol}}' - captures: - 1: meta.header.diff - 2: punctuation.separator.sequence.diff - 3: meta.diff.header.to-file meta.header.to-file.diff - 4: punctuation.definition.to-file.diff - pop: 1 - - include: pop-immediately - - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Context - diff-header-context: - - match: ^(\*{15}){{eol}} - scope: meta.separator.diff - captures: - 1: punctuation.separator.block.diff - - match: ^(\*{3})[ ](?!$) - captures: - 1: punctuation.definition.from-file.diff - push: diff-header-context-from-file - - diff-header-context-from-file: - - meta_scope: meta.diff.header.from-file meta.header.from-file.diff - - match: '{{eol}}' - set: maybe-diff-header-context-to-file - - include: dev-null - - include: path-separators - - include: date - - maybe-diff-header-context-to-file: - - match: ^(-{3})[ ](?!$) - captures: - 1: punctuation.definition.to-file.diff - push: diff-header-context-to-file - - match: ^ - pop: 1 - - diff-header-context-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 - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified diff-header-unified: - match: ^(-{3})[ ](?!$) @@ -142,34 +66,6 @@ contexts: line-ranges: - include: line-ranges-unified - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks - line-ranges-normal: - - match: ^-{3}{{eol}} - scope: meta.separator.diff punctuation.separator.block.diff - - match: ^\d+(?:(,)\d+)*(a|d|c)\d+(?:(,)\d+)*{{eol}} - scope: meta.diff.range.normal meta.range.normal.diff - captures: - 1: punctuation.separator.sequence.diff - 2: support.function.diff - 3: punctuation.separator.sequence.diff - - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - line-ranges-context: - - match: ^(-){3}(?= .+ -{4}{{eol}}) - scope: punctuation.definition.range.begin.diff - push: inside-line-ranges-context - - match: ^(\*){3}(?= .+ \*{4}{{eol}}) - scope: punctuation.definition.range.begin.diff - push: inside-line-ranges-context - - inside-line-ranges-context: - - meta_scope: meta.diff.range.context meta.range.context.diff meta.toc-list.hunk.diff - - include: pop-eol - - match: \1{4} - scope: punctuation.definition.range.end.diff - pop: 1 - - include: line-range-span - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified line-ranges-unified: - match: ^(@@)(?=[^@\n]+@@(?:\s|$)) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index e464c75a24..c3b8904a45 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -68,7 +68,7 @@ contexts: - include: path-separators diff-header-4equals-body: - - match: '( (-) )(.* (={4})){{eol}}' + - match: ( (-) )(.* (={4})){{eol}} captures: 1: meta.header.diff 2: punctuation.separator.sequence.diff diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 0faed649a2..92c7f3b41b 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -303,11 +303,11 @@ contexts: - include: path-separators diff-header: + - meta_prepend: true - meta_scope: meta.block.header.diff # Detect & switch context to changed content - match: ^(?=@|GIT binary) set: diff-content - - include: diff-header-unified # old mode # new mode From 3968c7b8048f4f653d75b48ec8ec572b9fc4c32b Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 17:40:52 +0100 Subject: [PATCH 100/127] [Diff] Re-use line-ranges context --- Git Formats/Git Diff.sublime-syntax | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 92c7f3b41b..6f54cc7b3f 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -372,9 +372,8 @@ contexts: diff-content: - meta_content_scope: meta.block.delta.diff - include: pop-before-diff-header + - include: line-ranges - include: binary-deltas - - include: line-ranges-combined - - include: line-ranges-unified - include: deltas-unified deltas-unified: @@ -413,8 +412,9 @@ contexts: ###[ COMBINED DIFF ]########################################################### - # https://git-scm.com/docs/diff-format#_combined_diff_format - line-ranges-combined: + line-ranges: + - meta_prepend: true + # https://git-scm.com/docs/diff-format#_combined_diff_format - include: line-range-combined-2 - include: line-range-combined-3 - include: line-range-combined-4 From 409c0d71356ebf1c92e36f8fe8933a6314864f27 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 20:00:31 +0100 Subject: [PATCH 101/127] [Diff] Re-use deltas context --- Git Formats/Git Diff.sublime-syntax | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 6f54cc7b3f..1eebf99cec 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -373,16 +373,15 @@ contexts: - meta_content_scope: meta.block.delta.diff - include: pop-before-diff-header - include: line-ranges - - include: binary-deltas - - include: deltas-unified + - include: deltas - deltas-unified: +###[ DELTAS ]################################################################## + + deltas: - meta_prepend: true - match: ^(?=-- {{eol}}) pop: 1 - - # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c - binary-deltas: + # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c - match: ^GIT binary patch scope: keyword.other.diff push: binary-delta-content From a6cadee4b3ada51e5be1d7509b85a2f242e5a0a5 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 18:38:10 +0100 Subject: [PATCH 102/127] [Diff] combined and unified line-ranges share same patterns The `inside-line-ranges-unified` only differs by meta scope. Hence include into `inside-line-ranges-combined` to avoid duplicates and move the context below the others, so including ones come first. --- Git Formats/Git Diff.sublime-syntax | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 1eebf99cec..71f922afce 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -419,16 +419,6 @@ contexts: - include: line-range-combined-4 - include: line-range-combined-5 - inside-line-ranges-combined: - - meta_scope: meta.diff.range.combined meta.range.combined.diff meta.toc-list.hunk.diff - - include: pop-eol - - match: \1 - scope: punctuation.definition.range.end.diff - pop: 1 - - include: line-range-span - - match: '[+-](?=[0-9])' - scope: support.function.diff - line-range-combined-2: - match: ^(@@{2})(?=[^@\n]+@@{2}(?:\s|$)) captures: @@ -517,6 +507,10 @@ contexts: scope: punctuation.definition.changed.diff push: line-changed + inside-line-ranges-combined: + - meta_scope: meta.diff.range.combined meta.range.combined.diff meta.toc-list.hunk.diff + - include: inside-line-ranges-unified + ###[ COMPONENTS ]############################################################## hash-empty-content: From ef4273953d62e7e06aac611f794916bbb29bad7e Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 19:42:14 +0100 Subject: [PATCH 103/127] [Diff] Tweak main key code style --- Diff/Diff (Unified).sublime-syntax | 2 -- Diff/Diff.sublime-syntax | 1 + Git Formats/Git Diff.sublime-syntax | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Diff/Diff (Unified).sublime-syntax b/Diff/Diff (Unified).sublime-syntax index cb03643fd6..498ef72e9e 100644 --- a/Diff/Diff (Unified).sublime-syntax +++ b/Diff/Diff (Unified).sublime-syntax @@ -7,8 +7,6 @@ scope: source.diff.unified version: 2 hidden: true -file_extensions: [] - contexts: main: - match: ^(?={{git_first_line}}) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index c3b8904a45..63c1250667 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -5,6 +5,7 @@ name: Diff scope: source.diff version: 2 + extends: Diff (Unified).sublime-syntax file_extensions: diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 71f922afce..970b654ad8 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -6,6 +6,7 @@ name: Git Diff scope: source.diff.git version: 2 + extends: Packages/Diff/Diff (Unified).sublime-syntax file_extensions: From a8a3992b032b734cfb38baabf63d8fc2e12f69b5 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 20:06:38 +0100 Subject: [PATCH 104/127] [Diff] Make Diff (Unified) non-standalone base syntax --- ...ime-syntax => Diff (Basic).sublime-syntax} | 22 ++++++------------- Diff/Diff.sublime-syntax | 14 ++++++++++-- Git Formats/Git Diff.sublime-syntax | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) rename Diff/{Diff (Unified).sublime-syntax => Diff (Basic).sublime-syntax} (93%) diff --git a/Diff/Diff (Unified).sublime-syntax b/Diff/Diff (Basic).sublime-syntax similarity index 93% rename from Diff/Diff (Unified).sublime-syntax rename to Diff/Diff (Basic).sublime-syntax index 498ef72e9e..eebd701795 100644 --- a/Diff/Diff (Unified).sublime-syntax +++ b/Diff/Diff (Basic).sublime-syntax @@ -1,26 +1,18 @@ %YAML 1.2 --- +# This is the common base syntax for Gnu Diff and Git Diff, +# which contains contexts, shared by both of them. +# It is not designed as standalone syntax and therefore does not expose +# anything when referenced or used directly. +# # https://www.sublimetext.com/docs/syntax.html # https://www.gnu.org/software/diffutils/manual/diffutils.html -name: Unified Diff -scope: source.diff.unified +scope: source.diff.basic version: 2 hidden: true contexts: - main: - - match: ^(?={{git_first_line}}) - embed: Packages/Git Formats/Git Diff.sublime-syntax#email-first-line - escape: (?!) - # Hack for unit tests - - include: incomplete-line - - match: ^ - push: diffs - - diffs: - - include: line-ranges - - include: diff-header - - include: deltas + main: [] ###[ HEADERS ]################################################################# diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 63c1250667..2c22b41bdf 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -6,7 +6,7 @@ name: Diff scope: source.diff version: 2 -extends: Diff (Unified).sublime-syntax +extends: Diff (Basic).sublime-syntax file_extensions: - diff @@ -24,9 +24,19 @@ first_line_match: |- ) contexts: + main: + - match: ^(?={{git_first_line}}) + embed: Packages/Git Formats/Git Diff.sublime-syntax#email-first-line + escape: (?!) + # Hack for unit tests + - include: incomplete-line + - match: ^ + push: diffs diffs: - - meta_append: true + - include: line-ranges + - include: diff-header + - include: deltas - include: diff3-normal # Diff3 Edit conflicts with non-diff3 Normal mode, so it's off by default. # With branching, it could probably be enabled, too. diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 970b654ad8..9eea372a37 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -7,7 +7,7 @@ name: Git Diff scope: source.diff.git version: 2 -extends: Packages/Diff/Diff (Unified).sublime-syntax +extends: Packages/Diff/Diff (Basic).sublime-syntax file_extensions: - diff.eml From 07457a4fc81da1fb8b57f8534329a50decbb5061 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 20:09:01 +0100 Subject: [PATCH 105/127] [Diff] Simplify eol --- Diff/Diff (Basic).sublime-syntax | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Diff/Diff (Basic).sublime-syntax b/Diff/Diff (Basic).sublime-syntax index eebd701795..f19c045039 100644 --- a/Diff/Diff (Basic).sublime-syntax +++ b/Diff/Diff (Basic).sublime-syntax @@ -47,7 +47,7 @@ contexts: - include: diff-header-unified-file-comment diff-header-unified-file-comment: - - match: \s+(\(.+\))(?=$) + - match: \s+(\(.+\))$ captures: 1: comment.block.diff @@ -127,7 +127,7 @@ contexts: - include: trailing-whitespace trailing-whitespace: - - match: '[ \t]*(?=$)' + - match: '[ \t]*$' scope: meta.whitespace.trailing.diff ###[ COMPONENTS ]############################################################## @@ -178,7 +178,7 @@ contexts: pop: 1 pop-before-eol: - - match: (?={{eol}}) + - match: $ pop: 1 variables: From 4f9d6dc1bd61c59b0d8ad498c225ab98bb1e8461 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 20:19:42 +0100 Subject: [PATCH 106/127] [Diff] Merge unique contexts This commit merges patterns from `diff-header-context` and `diff-header-unified` to `diff-header`, as those are included only once. --- Diff/Diff (Basic).sublime-syntax | 15 +++-------- Diff/Diff.sublime-syntax | 39 ++++++++++------------------- Git Formats/Git Diff.sublime-syntax | 38 ++++++++++------------------ 3 files changed, 29 insertions(+), 63 deletions(-) diff --git a/Diff/Diff (Basic).sublime-syntax b/Diff/Diff (Basic).sublime-syntax index f19c045039..2b9cdde9fe 100644 --- a/Diff/Diff (Basic).sublime-syntax +++ b/Diff/Diff (Basic).sublime-syntax @@ -17,10 +17,7 @@ contexts: ###[ HEADERS ]################################################################# diff-header: - - include: diff-header-unified - - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified - diff-header-unified: + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified - match: ^(-{3})[ ](?!$) captures: 1: punctuation.definition.from-file.diff @@ -54,10 +51,7 @@ contexts: ###[ RANGES ]################################################################## line-ranges: - - include: line-ranges-unified - - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified - line-ranges-unified: + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified - match: ^(@@)(?=[^@\n]+@@(?:\s|$)) captures: 1: punctuation.definition.range.begin.diff @@ -88,10 +82,7 @@ contexts: ###[ DELTAS ]################################################################## deltas: - - include: deltas-unified - - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified - deltas-unified: + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified - match: ^\+ scope: punctuation.definition.inserted.diff push: line-inserted diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 2c22b41bdf..66378f7a6c 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -45,7 +45,15 @@ contexts: diff-header: - meta_prepend: true - - include: diff-header-context + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Context + - match: ^(\*{15}){{eol}} + scope: meta.separator.diff + captures: + 1: punctuation.separator.block.diff + - match: ^(\*{3})[ ](?!$) + captures: + 1: punctuation.definition.from-file.diff + push: diff-header-context-from-file # https://svnbook.red-bean.com/en/1.7/svn-book.html#svn.ref.svn.c.patch - match: ^(={67}|={78}|_{67}){{eol}} @@ -88,17 +96,6 @@ contexts: pop: 1 - include: pop-immediately - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Context - diff-header-context: - - match: ^(\*{15}){{eol}} - scope: meta.separator.diff - captures: - 1: punctuation.separator.block.diff - - match: ^(\*{3})[ ](?!$) - captures: - 1: punctuation.definition.from-file.diff - push: diff-header-context-from-file - diff-header-context-from-file: - meta_scope: meta.diff.header.from-file meta.header.from-file.diff - match: '{{eol}}' @@ -126,11 +123,7 @@ contexts: line-ranges: - meta_prepend: true - - include: line-ranges-normal - - include: line-ranges-context - - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks - line-ranges-normal: + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks - match: ^-{3}{{eol}} scope: meta.separator.diff punctuation.separator.block.diff - match: ^\d+(?:(,)\d+)*(a|d|c)\d+(?:(,)\d+)*{{eol}} @@ -140,8 +133,7 @@ contexts: 2: support.function.diff 3: punctuation.separator.sequence.diff - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - line-ranges-context: + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - match: ^(-){3}(?= .+ -{4}{{eol}}) scope: punctuation.definition.range.begin.diff push: inside-line-ranges-context @@ -161,11 +153,7 @@ contexts: deltas: - meta_prepend: true - - include: deltas-normal - - include: deltas-context - - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal - deltas-normal: + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal - match: ^> ? scope: punctuation.definition.inserted.diff push: line-inserted @@ -174,8 +162,7 @@ contexts: push: line-deleted - include: incomplete-line - # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - deltas-context: + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - match: ^\+ ? scope: punctuation.definition.inserted.diff push: line-inserted diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 9eea372a37..9468267a51 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -415,16 +415,22 @@ contexts: line-ranges: - meta_prepend: true # https://git-scm.com/docs/diff-format#_combined_diff_format - - include: line-range-combined-2 - - include: line-range-combined-3 - - include: line-range-combined-4 - - include: line-range-combined-5 - - line-range-combined-2: - match: ^(@@{2})(?=[^@\n]+@@{2}(?:\s|$)) captures: 1: punctuation.definition.range.begin.diff - push: [deltas-combined-2, hunk-name, inside-line-ranges-combined] + push: [deltas-combined-2, hunk-name, inside-diff-line-ranges-combined] + - match: ^(@@{3})(?=[^@\n]+@@{3}(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [deltas-combined-3, hunk-name, inside-diff-line-ranges-combined] + - match: ^(@@{4})(?=[^@\n]+@@{4}(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [deltas-combined-4, hunk-name, inside-diff-line-ranges-combined] + - match: ^(@@{5})(?=[^@\n]+@@{5}(?:\s|$)) + captures: + 1: punctuation.definition.range.begin.diff + push: [deltas-combined-5, hunk-name, inside-diff-line-ranges-combined] deltas-combined-2: - include: pop-empty-line @@ -442,12 +448,6 @@ contexts: scope: punctuation.definition.changed.diff push: line-changed - line-range-combined-3: - - match: ^(@@{3})(?=[^@\n]+@@{3}(?:\s|$)) - captures: - 1: punctuation.definition.range.begin.diff - push: [deltas-combined-3, hunk-name, inside-line-ranges-combined] - deltas-combined-3: - include: pop-empty-line - match: ^[ ]{3} @@ -464,12 +464,6 @@ contexts: scope: punctuation.definition.changed.diff push: line-changed - line-range-combined-4: - - match: ^(@@{4})(?=[^@\n]+@@{4}(?:\s|$)) - captures: - 1: punctuation.definition.range.begin.diff - push: [deltas-combined-4, hunk-name, inside-line-ranges-combined] - deltas-combined-4: - include: pop-empty-line - match: ^[ ]{4} @@ -486,12 +480,6 @@ contexts: scope: punctuation.definition.changed.diff push: line-changed - line-range-combined-5: - - match: ^(@@{5})(?=[^@\n]+@@{5}(?:\s|$)) - captures: - 1: punctuation.definition.range.begin.diff - push: [deltas-combined-5, hunk-name, inside-line-ranges-combined] - deltas-combined-5: - include: pop-empty-line - match: ^[ ]{5} From 563c3b07869f8279d2640739103df0d4d36e4dd0 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 20:26:25 +0100 Subject: [PATCH 107/127] [Diff] Rename line-range contexts To clearly distinguish diff- vs. patch- vs. email- in Git Diff --- Diff/Diff (Basic).sublime-syntax | 6 +++--- Diff/Diff.sublime-syntax | 10 +++++----- Git Formats/Git Diff.sublime-syntax | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Diff/Diff (Basic).sublime-syntax b/Diff/Diff (Basic).sublime-syntax index 2b9cdde9fe..882f7c3dee 100644 --- a/Diff/Diff (Basic).sublime-syntax +++ b/Diff/Diff (Basic).sublime-syntax @@ -50,14 +50,14 @@ contexts: ###[ RANGES ]################################################################## - line-ranges: + diff-line-ranges: # https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified - match: ^(@@)(?=[^@\n]+@@(?:\s|$)) captures: 1: punctuation.definition.range.begin.diff - push: [hunk-name, inside-line-ranges-unified] + push: [hunk-name, inside-diff-line-ranges-unified] - inside-line-ranges-unified: + inside-diff-line-ranges-unified: - meta_scope: meta.diff.range.unified meta.range.unified.diff meta.toc-list.hunk.diff - include: pop-eol - match: \1 diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 66378f7a6c..1beef986d9 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -34,7 +34,7 @@ contexts: push: diffs diffs: - - include: line-ranges + - include: diff-line-ranges - include: diff-header - include: deltas - include: diff3-normal @@ -121,7 +121,7 @@ contexts: ###[ RANGES ]################################################################## - line-ranges: + diff-line-ranges: - meta_prepend: true # https://www.gnu.org/software/diffutils/manual/diffutils.html#Hunks - match: ^-{3}{{eol}} @@ -136,12 +136,12 @@ contexts: # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - match: ^(-){3}(?= .+ -{4}{{eol}}) scope: punctuation.definition.range.begin.diff - push: inside-line-ranges-context + push: inside-diff-line-ranges-context - match: ^(\*){3}(?= .+ \*{4}{{eol}}) scope: punctuation.definition.range.begin.diff - push: inside-line-ranges-context + push: inside-diff-line-ranges-context - inside-line-ranges-context: + inside-diff-line-ranges-context: - meta_scope: meta.diff.range.context meta.range.context.diff meta.toc-list.hunk.diff - include: pop-eol - match: \1{4} diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 9468267a51..91adb19e2a 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -373,7 +373,7 @@ contexts: diff-content: - meta_content_scope: meta.block.delta.diff - include: pop-before-diff-header - - include: line-ranges + - include: diff-line-ranges - include: deltas ###[ DELTAS ]################################################################## @@ -412,7 +412,7 @@ contexts: ###[ COMBINED DIFF ]########################################################### - line-ranges: + diff-line-ranges: - meta_prepend: true # https://git-scm.com/docs/diff-format#_combined_diff_format - match: ^(@@{2})(?=[^@\n]+@@{2}(?:\s|$)) @@ -496,9 +496,9 @@ contexts: scope: punctuation.definition.changed.diff push: line-changed - inside-line-ranges-combined: + inside-diff-line-ranges-combined: - meta_scope: meta.diff.range.combined meta.range.combined.diff meta.toc-list.hunk.diff - - include: inside-line-ranges-unified + - include: inside-diff-line-ranges-unified ###[ COMPONENTS ]############################################################## From 8eded5f504c42359cf562f60b8cab97fa75c141b Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 20:28:12 +0100 Subject: [PATCH 108/127] [Diff] Rename delta contexts --- Diff/Diff (Basic).sublime-syntax | 2 +- Diff/Diff.sublime-syntax | 4 ++-- Git Formats/Git Diff.sublime-syntax | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Diff/Diff (Basic).sublime-syntax b/Diff/Diff (Basic).sublime-syntax index 882f7c3dee..b01fe60004 100644 --- a/Diff/Diff (Basic).sublime-syntax +++ b/Diff/Diff (Basic).sublime-syntax @@ -81,7 +81,7 @@ contexts: ###[ DELTAS ]################################################################## - deltas: + diff-deltas: # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified - match: ^\+ scope: punctuation.definition.inserted.diff diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 1beef986d9..de96df60e4 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -36,7 +36,7 @@ contexts: diffs: - include: diff-line-ranges - include: diff-header - - include: deltas + - include: diff-deltas - include: diff3-normal # Diff3 Edit conflicts with non-diff3 Normal mode, so it's off by default. # With branching, it could probably be enabled, too. @@ -151,7 +151,7 @@ contexts: ###[ DELTAS ]################################################################## - deltas: + diff-deltas: - meta_prepend: true # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal - match: ^> ? diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 91adb19e2a..b85106fd32 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -374,20 +374,20 @@ contexts: - meta_content_scope: meta.block.delta.diff - include: pop-before-diff-header - include: diff-line-ranges - - include: deltas + - include: diff-deltas ###[ DELTAS ]################################################################## - deltas: + diff-deltas: - meta_prepend: true - match: ^(?=-- {{eol}}) pop: 1 # https://github.com/git/git/commit/051308f6e9cebeb76b8fb4f52b7e9e7ce064445c - match: ^GIT binary patch scope: keyword.other.diff - push: binary-delta-content + push: binary-diff-delta-content - binary-delta-content: + binary-diff-delta-content: # Binary type - match: ^(delta|literal) ([0-9]+) captures: From 10c39685ae8351bf3e1819013135389d6f5fdc71 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 20:37:07 +0100 Subject: [PATCH 109/127] [Diff] Add separator --- Diff/Diff (Basic).sublime-syntax | 2 ++ Git Formats/Git Diff.sublime-syntax | 1 + 2 files changed, 3 insertions(+) diff --git a/Diff/Diff (Basic).sublime-syntax b/Diff/Diff (Basic).sublime-syntax index b01fe60004..25b72a64f3 100644 --- a/Diff/Diff (Basic).sublime-syntax +++ b/Diff/Diff (Basic).sublime-syntax @@ -172,6 +172,8 @@ contexts: - match: $ pop: 1 +############################################################################### + variables: git_hash40: '[0-9a-fA-F]{40}' git_hash64: '[0-9a-fA-F]{64}' diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index b85106fd32..57d8c525fa 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -538,6 +538,7 @@ contexts: - match: ^{{next_diff_header}} pop: 1 +############################################################################### variables: git_hash: '[0-9a-fA-F]{7,64}' From e9b57aec71ecd295ac83bb6fcc3235671ca718dd Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 20:40:24 +0100 Subject: [PATCH 110/127] [Diff] Rename date context to timestamps --- Diff/Diff (Basic).sublime-syntax | 6 +++--- Diff/Diff.sublime-syntax | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Diff/Diff (Basic).sublime-syntax b/Diff/Diff (Basic).sublime-syntax index 25b72a64f3..a3acd7f467 100644 --- a/Diff/Diff (Basic).sublime-syntax +++ b/Diff/Diff (Basic).sublime-syntax @@ -32,7 +32,7 @@ contexts: - include: pop-eol - include: dev-null - include: path-separators - - include: date + - include: timestamps - include: diff-header-unified-file-comment diff-header-unified-to-file: @@ -40,7 +40,7 @@ contexts: - include: pop-eol - include: dev-null - include: path-separators - - include: date + - include: timestamps - include: diff-header-unified-file-comment diff-header-unified-file-comment: @@ -135,7 +135,7 @@ contexts: - match: \B\.(?=/|\\) scope: constant.other.path.self.diff - date: + timestamps: # 1970-01-01 00:00:00 +0000 - match: \b1970(-)01(-)01 0?0(:)00(:)00(?:(\.)0+)?(?:[ ]([+-]?0000|UTC))? scope: meta.date.diff constant.language.null.diff diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index de96df60e4..d56a038233 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -102,7 +102,7 @@ contexts: set: maybe-diff-header-context-to-file - include: dev-null - include: path-separators - - include: date + - include: timestamps maybe-diff-header-context-to-file: - match: ^(-{3})[ ](?!$) @@ -117,7 +117,7 @@ contexts: - include: pop-eol - include: dev-null - include: path-separators - - include: date + - include: timestamps ###[ RANGES ]################################################################## From 0447a060b82fe7b07d0b75d8d6b8a83d7b154b39 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 20:46:02 +0100 Subject: [PATCH 111/127] [Diff] Include eol into meta.separator --- Git Formats/Git Diff.sublime-syntax | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 57d8c525fa..dec09429fb 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -280,8 +280,9 @@ contexts: # that once inside this context, you cannot leave. That seems to be how # it works for these files. - match: ^(-- ){{eol}} + scope: meta.separator.diff captures: - 1: meta.separator.diff punctuation.section.block.diff + 1: punctuation.section.block.diff set: signature signature: From 46ff97538f52c1d7e3a8b7f3c766b058b0a00c3b Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 17 Dec 2024 21:13:18 +0100 Subject: [PATCH 112/127] [Diff] Rename file-header-continue to diff-file-header --- Git Formats/Git Diff.sublime-syntax | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index dec09429fb..7c48b43001 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -273,7 +273,7 @@ contexts: 1: variable.function.diff 2: variable.parameter.diff 3: punctuation.definition.parameter.diff - push: [diff-header, file-header-continue] + push: [diff-header, diff-file-header] # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt # This is the Git version unless otherwise configured. You will notice @@ -288,7 +288,7 @@ contexts: signature: - meta_content_scope: comment.block.diff - file-header-continue: + diff-file-header: - meta_scope: meta.toc-list.git - include: pop-eol # TODO: Quoted file names https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath From e076ddc37df03377f56b5b2230a673d5395f8abe Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 18 Dec 2024 09:14:31 +0100 Subject: [PATCH 113/127] [Diff] Remove redundant includes --- Diff/Diff.sublime-syntax | 2 -- 1 file changed, 2 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index d56a038233..84f115832d 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -160,7 +160,6 @@ contexts: - match: ^< ? scope: punctuation.definition.deleted.diff push: line-deleted - - include: incomplete-line # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - match: ^\+ ? @@ -172,7 +171,6 @@ contexts: - match: ^! ? scope: punctuation.definition.changed.diff push: line-changed - - include: incomplete-line ###[ DIFF3 ]################################################################### From 18fb06efe9182a1a9829b6b8826968ba3738f90e Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 18 Dec 2024 09:20:57 +0100 Subject: [PATCH 114/127] [Diff] Fix diff3 edit format 1. introduce named contexts for content blocks 2. re-include `diff3-edit` 3. add some tests --- Diff/Diff.sublime-syntax | 25 ++++++++++++++++--------- Diff/tests/syntax_test_diff.diff | 19 ++++++++++++++++++- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 84f115832d..11188066ac 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -37,6 +37,7 @@ contexts: - include: diff-line-ranges - include: diff-header - include: diff-deltas + - include: diff3-edit - include: diff3-normal # Diff3 Edit conflicts with non-diff3 Normal mode, so it's off by default. # With branching, it could probably be enabled, too. @@ -202,25 +203,31 @@ contexts: captures: 1: meta.diff.range.normal meta.range.normal.diff 2: support.function.diff - push: - - meta_content_scope: meta.block.diff markup.inserted.diff - - include: diff3-edit-end + push: diff3-edit-inserted - match: ^(\d+)(d){{eol}} captures: 1: meta.diff.range.normal meta.range.normal.diff 2: support.function.diff - push: - - meta_content_scope: meta.block.diff markup.deleted.diff - - include: diff3-edit-end + push: diff3-edit-deleted - match: ^(\d+)(c){{eol}} captures: 1: meta.diff.range.normal meta.range.normal.diff 2: support.function.diff - push: - - meta_content_scope: meta.block.diff markup.modified.diff - - include: diff3-edit-end + push: diff3-edit-changed + + diff3-edit-inserted: + - meta_content_scope: meta.block.diff markup.inserted.diff + - include: diff3-edit-end + + diff3-edit-deleted: + - meta_content_scope: meta.block.diff markup.deleted.diff + - include: diff3-edit-end + + diff3-edit-changed: + - meta_content_scope: meta.block.diff markup.changed.diff + - include: diff3-edit-end diff3-edit-end: - match: ^\.$ diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index d3e487e9ff..51bc99fc42 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -262,12 +262,29 @@ Diff3 Normal Format https://www.gnu.org/software/diffutils/manual/diffutils.html Diff3 Edit Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Selecting-Which-Changes-to-Incorporate 11a - +\ <- meta.diff.range.normal meta.range.normal.diff +\^ meta.diff.range.normal meta.range.normal.diff +\ ^ support.function.diff -- The Way of Lao-Tzu, tr. Wing-tsit Chan +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.diff markup.inserted.diff . +\ <- punctuation.section.block.end.diff 8c +\ <- meta.diff.range.normal meta.range.normal.diff +\^ support.function.diff so we may see their result. +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.diff markup.changed.diff +. +\ <- punctuation.section.block.end.diff +24d +\ <- meta.diff.range.normal meta.range.normal.diff +\^ meta.diff.range.normal meta.range.normal.diff +\ ^ support.function.diff + + This is removed content +\^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.diff markup.deleted.diff . +\ <- punctuation.section.block.end.diff SVN sample https://svnbook.red-bean.com/en/1.7/svn-book.html#idm10685 From 13c33f67d365f4d2c6c7fd69112980c6b55bf61a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 18 Dec 2024 12:03:09 +0100 Subject: [PATCH 115/127] [Diff] Hunks and ranges This commit... 1. scopes `,` in ranges `punctuation.separator.range` as numbers before and after denote beginning and end of modified content range, but no sequence of arbitrary numbers. 2. scopes diff3 hunks `meta.hunk` 3. scope whole diff3 change markers `meta.range` to achieve same segmentation as for `@@ ... @@` range markers in unified diffs. 4. add diff3 modifications to toc-list Scope change markers `meta.toc-list`. Exclude eol to correctly separate them in symbol list. --- Diff/Diff.sublime-syntax | 31 +++++++++------ Diff/tests/syntax_test_diff.diff | 67 ++++++++++++++++++++++++++++---- 2 files changed, 78 insertions(+), 20 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 11188066ac..1eb3b8371a 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -91,7 +91,7 @@ contexts: - match: ( (-) )(.* (={4})){{eol}} captures: 1: meta.header.diff - 2: punctuation.separator.sequence.diff + 2: punctuation.separator.range.diff 3: meta.diff.header.to-file meta.header.to-file.diff 4: punctuation.definition.to-file.diff pop: 1 @@ -130,9 +130,9 @@ contexts: - match: ^\d+(?:(,)\d+)*(a|d|c)\d+(?:(,)\d+)*{{eol}} scope: meta.diff.range.normal meta.range.normal.diff captures: - 1: punctuation.separator.sequence.diff + 1: punctuation.separator.range.diff 2: support.function.diff - 3: punctuation.separator.sequence.diff + 3: punctuation.separator.range.diff # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context - match: ^(-){3}(?= .+ -{4}{{eol}}) @@ -177,21 +177,25 @@ contexts: # https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-diff3-Normal diff3-normal: - - match: ^====[1-3]?{{eol}} - scope: punctuation.section.block.diff + - match: ^====([1-3]?){{eol}} + scope: meta.hunk.diff punctuation.section.hunk.diff + captures: + 1: constant.numeric.from-file.diff - - match: ^([1-3])(:)(\d+(a)|\d+(?:(,)\d+)?(c)){{eol}} - scope: meta.mapping.diff + - match: ^(([1-3])(:)(?:\d+(a)|\d+(?:(,)\d+)?(c))){{eol}} + scope: meta.diff.range.normal meta.range.normal.diff captures: - 1: meta.mapping.key.diff meta.number.integer.decimal.diff constant.numeric.value.diff - 2: punctuation.separator.key-value.diff - 3: meta.mapping.value.diff meta.diff.range.normal meta.range.normal.diff + 1: meta.toc-list.hunk.diff + 2: constant.numeric.from-file.diff + 3: punctuation.separator.file.diff 4: support.function.diff - 5: punctuation.separator.sequence.diff + 5: punctuation.separator.range.diff 6: support.function.diff push: diff3-normal-change diff3-normal-change: + - meta_scope: meta.hunk.diff + - meta_content_scope: meta.block.diff - match: ^(?:\t| ) push: line-changed - match: ^ @@ -218,18 +222,21 @@ contexts: push: diff3-edit-changed diff3-edit-inserted: + - meta_scope: meta.hunk.diff - meta_content_scope: meta.block.diff markup.inserted.diff - include: diff3-edit-end diff3-edit-deleted: + - meta_scope: meta.hunk.diff - meta_content_scope: meta.block.diff markup.deleted.diff - include: diff3-edit-end diff3-edit-changed: + - meta_scope: meta.hunk.diff - meta_content_scope: meta.block.diff markup.changed.diff - include: diff3-edit-end diff3-edit-end: - match: ^\.$ - scope: punctuation.section.block.end.diff + scope: punctuation.terminator.hunk.diff pop: 1 diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 51bc99fc42..246f10901f 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -115,18 +115,38 @@ Index: lao Normal Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Normal 1,2d0 +\ <- meta.diff.range.normal meta.range.normal.diff +\^^^^ meta.diff.range.normal meta.range.normal.diff +\^ punctuation.separator.range.diff +\ ^ support.function.diff < The Way that can be told of is not the eternal Way; < The name that can be named is not the eternal name. 4c2,3 +\ <- meta.diff.range.normal meta.range.normal.diff +\^^^^ meta.diff.range.normal meta.range.normal.diff +\^ support.function.diff +\ ^ punctuation.separator.range.diff < The Named is the mother of all things. +\ <- markup.deleted.diff punctuation.definition.deleted.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff +\^ punctuation.definition.deleted.diff --- +\ <- meta.separator.diff punctuation.separator.block.diff +\^^ meta.separator.diff punctuation.separator.block.diff > The named is the mother of all things. > \^ - meta.whitespace 11a11,13 +\ <- meta.diff.range.normal meta.range.normal.diff +\^^^^^^^ meta.diff.range.normal meta.range.normal.diff +\ ^ support.function.diff +\ ^ punctuation.separator.range.diff > They both may be called deep and profound. > Deeper and more profound, > The door of all subtleties! +\ <- markup.inserted.diff punctuation.definition.inserted.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff +\^ punctuation.definition.inserted.diff Context Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Context @@ -231,12 +251,30 @@ Unified Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Exam Diff3 Normal Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-diff3-Normal ====2 +\ <- meta.hunk.diff punctuation.section.hunk.diff +\^^^^^ meta.hunk.diff punctuation.section.hunk.diff +\ ^ constant.numeric.from-file.diff 1:1,2c +\ <- meta.hunk.diff meta.diff.range.normal meta.range.normal.diff meta.toc-list.hunk.diff constant.numeric.from-file.diff +\^^^^^ meta.hunk.diff meta.diff.range.normal meta.range.normal.diff meta.toc-list.hunk.diff +\^ punctuation.separator.file.diff +\ ^ punctuation.separator.range.diff +\ ^ support.function.diff +\ ^ - meta.toc-list 3:1,2c The Way that can be told of is not the eternal Way; The name that can be named is not the eternal name. +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.hunk.diff meta.block.diff markup.changed.diff 2:0a +\ <- meta.hunk.diff meta.diff.range.normal meta.range.normal.diff meta.toc-list.hunk.diff constant.numeric.from-file.diff +\^^^ meta.hunk.diff meta.diff.range.normal meta.range.normal.diff meta.toc-list.hunk.diff +\^ punctuation.separator.file.diff +\ ^ support.function.diff +\ ^ - meta.toc-list ====1 +\ <- meta.hunk.diff punctuation.section.hunk.diff +\^^^^^ meta.hunk.diff punctuation.section.hunk.diff +\ ^ constant.numeric.from-file.diff 1:4c The Named is the mother of all things. 2:2,3c @@ -244,12 +282,22 @@ Diff3 Normal Format https://www.gnu.org/software/diffutils/manual/diffutils.html The named is the mother of all things. ====3 +\ <- meta.hunk.diff punctuation.section.hunk.diff +\^^^^^ meta.hunk.diff punctuation.section.hunk.diff +\ ^ constant.numeric.from-file.diff 1:8c +\ <- meta.hunk.diff meta.diff.range.normal meta.range.normal.diff meta.toc-list.hunk.diff constant.numeric.from-file.diff +\^^^ meta.hunk.diff meta.diff.range.normal meta.range.normal.diff meta.toc-list.hunk.diff +\^ punctuation.separator.file.diff +\ ^ support.function.diff +\ ^ - meta.toc-list 2:7c so we may see their outcome. 3:9c so we may see their result. ==== +\ <- meta.hunk.diff punctuation.section.hunk.diff +\^^^^ meta.hunk.diff punctuation.section.hunk.diff 1:11a 2:11,13c They both may be called deep and profound. @@ -258,33 +306,36 @@ Diff3 Normal Format https://www.gnu.org/software/diffutils/manual/diffutils.html 3:13,14c -- The Way of Lao-Tzu, tr. Wing-tsit Chan +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.hunk.diff meta.block.diff markup.changed.diff Diff3 Edit Format https://www.gnu.org/software/diffutils/manual/diffutils.html#Selecting-Which-Changes-to-Incorporate 11a -\ <- meta.diff.range.normal meta.range.normal.diff +\ <- meta.hunk.diff meta.diff.range.normal meta.range.normal.diff +\^^^ meta.hunk.diff \^ meta.diff.range.normal meta.range.normal.diff \ ^ support.function.diff -- The Way of Lao-Tzu, tr. Wing-tsit Chan -\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.diff markup.inserted.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.hunk.diff meta.block.diff markup.inserted.diff . -\ <- punctuation.section.block.end.diff +\ <- meta.hunk.diff punctuation.terminator.hunk.diff 8c -\ <- meta.diff.range.normal meta.range.normal.diff +\ <- meta.hunk.diff meta.diff.range.normal meta.range.normal.diff +\^^ meta.hunk.diff \^ support.function.diff so we may see their result. -\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.diff markup.changed.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.hunk.diff meta.block.diff markup.changed.diff . -\ <- punctuation.section.block.end.diff +\ <- meta.hunk.diff punctuation.terminator.hunk.diff 24d \ <- meta.diff.range.normal meta.range.normal.diff \^ meta.diff.range.normal meta.range.normal.diff \ ^ support.function.diff This is removed content -\^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.diff markup.deleted.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^ meta.hunk.diff meta.block.diff markup.deleted.diff . -\ <- punctuation.section.block.end.diff +\ <- meta.hunk.diff punctuation.terminator.hunk.diff SVN sample https://svnbook.red-bean.com/en/1.7/svn-book.html#idm10685 From d13e9fb2cc9ceec3804fee545094f57c6d6a31ba Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Wed, 18 Dec 2024 14:48:48 -0500 Subject: [PATCH 116/127] [Diff] Fold Conflict syntax back in --- Diff/Conflict.sublime-syntax | 97 -------------- Diff/Diff.sublime-syntax | 93 ++++++++++++- Diff/tests/syntax_test_conflict.conflict | 157 ---------------------- Diff/tests/syntax_test_diff.diff | 159 +++++++++++++++++++++++ 4 files changed, 250 insertions(+), 256 deletions(-) delete mode 100644 Diff/Conflict.sublime-syntax delete mode 100644 Diff/tests/syntax_test_conflict.conflict diff --git a/Diff/Conflict.sublime-syntax b/Diff/Conflict.sublime-syntax deleted file mode 100644 index 740684f717..0000000000 --- a/Diff/Conflict.sublime-syntax +++ /dev/null @@ -1,97 +0,0 @@ -%YAML 1.2 ---- -# https://www.sublimetext.com/docs/syntax.html -# https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 -name: Conflict -scope: source.conflict -version: 2 - -file_extensions: - - conflict - -contexts: - main: - - include: conflicts - - # Utility context for others to use - conflict-markers: - - match: ^({{any}})\s*({{identifier}})\s*{{eol}} - captures: - 1: punctuation.section.block.conflict - 2: entity.name.section.conflict - - conflicts: - - match: ^(?={{begin}}) - push: - - conflict - - conflict-marker-start - - conflict: - - meta_scope: meta.block.conflict - - match: '' - pop: 1 - - conflict-marker-start: - - match: '{{begin}}' - scope: punctuation.section.block.begin.conflict - - match: (?:({{identifier}})\s*)?{{eol}} - captures: - 1: entity.name.section.conflict - set: deleted-lines - - base-marker-start: - - match: '{{base}}' - scope: punctuation.section.block.conflict - - match: (?:({{identifier}})\s*)?{{eol}} - captures: - 1: entity.name.section.conflict - set: base-lines - - split-marker-start: - - match: '{{split}}' - scope: punctuation.section.block.conflict - - match: (?:({{identifier}})\s*)?{{eol}} - captures: - 1: entity.name.section.conflict - set: new-lines - - deleted-lines: - - meta_content_scope: markup.deleted.conflict - - match: ^(?={{base}}) - set: base-marker-start - - match: ^(?={{split}}) - set: split-marker-start - - include: invalid-conflict-marker - - base-lines: - - meta_content_scope: comment.block.conflict - - match: ^(?={{split}}) - set: split-marker-start - - include: invalid-conflict-marker - - new-lines: - - meta_content_scope: markup.inserted.conflict - - match: ^({{end}})\s*(?:({{identifier}})\s*)?{{eol}} - captures: - 1: punctuation.section.block.end.conflict - 2: entity.name.section.conflict - pop: 1 - # Nested conflicts in ReReRe - - include: conflicts - - include: invalid-conflict-marker - - invalid-conflict-marker: - - match: ^(?:{{any}}) - scope: invalid.illegal.conflict - - -variables: - eol: (?:$\n?) - - begin: <{5,} - end: '>{5,}' - split: ={5,} - base: \|{5,} - any: (?:{{begin}}|{{end}}|{{split}}|{{base}}) - - identifier: (?:\S.*?) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 1eb3b8371a..4dca8144e6 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -36,11 +36,10 @@ contexts: diffs: - include: diff-line-ranges - include: diff-header + - include: conflicts - include: diff-deltas - include: diff3-edit - include: diff3-normal - # Diff3 Edit conflicts with non-diff3 Normal mode, so it's off by default. - # With branching, it could probably be enabled, too. ###[ HEADERS ]################################################################# @@ -240,3 +239,93 @@ contexts: - match: ^\.$ scope: punctuation.terminator.hunk.diff pop: 1 + +###[ CONFLICTS ]############################################################### + + # Utility context for other files to use + conflict-markers: + - match: ^({{conflict_any}})\s*({{conflict_identifier}})\s*{{eol}} + captures: + 1: punctuation.section.block.diff + 2: entity.name.section.diff + + conflicts: + - match: ^(?={{conflict_begin}}) + push: + - conflict + - conflict-marker-start + + conflict: + - meta_scope: meta.block.conflict.diff + - match: '' + pop: 1 + + conflict-marker-start: + - match: '{{conflict_begin}}' + scope: punctuation.section.block.begin.diff + - match: (?:({{conflict_identifier}})\s*)?{{eol}} + captures: + 1: entity.name.section.diff + set: conflict-deleted-lines + + conflict-base-marker-start: + - match: '{{conflict_base}}' + scope: punctuation.section.block.diff + - match: (?:({{conflict_identifier}})\s*)?{{eol}} + captures: + 1: entity.name.section.diff + set: conflict-base-lines + + conflict-split-marker-start: + - match: '{{conflict_split}}' + scope: punctuation.section.block.diff + - match: (?:({{conflict_identifier}})\s*)?{{eol}} + captures: + 1: entity.name.section.diff + set: conflict-new-lines + + conflict-deleted-lines: + - meta_content_scope: markup.deleted.diff + - match: ^(?={{conflict_base}}) + set: conflict-base-marker-start + - match: ^(?={{conflict_split}}) + set: conflict-split-marker-start + - include: invalid-conflict-marker + + conflict-base-lines: + - meta_content_scope: comment.block.diff + - match: ^(?={{conflict_split}}) + set: conflict-split-marker-start + - include: invalid-conflict-marker + + conflict-new-lines: + - meta_content_scope: markup.inserted.diff + - match: ^({{conflict_end}})\s*(?:({{conflict_identifier}})\s*)?{{eol}} + captures: + 1: punctuation.section.block.end.diff + 2: entity.name.section.diff + pop: 1 + # Nested conflicts in Git ReReRe + - include: conflicts + - include: invalid-conflict-marker + + invalid-conflict-marker: + - match: ^(?:{{conflict_any}}) + scope: invalid.illegal.conflict.diff + +############################################################################### + +variables: + conflict_begin: <{5,} + conflict_end: '>{5,}' + conflict_split: ={5,} + conflict_base: \|{5,} + conflict_any: |- + (?x: + {{conflict_begin}} + | {{conflict_end}} + | {{conflict_split}} + | {{conflict_base}} + ) + + conflict_identifier: (?:\S.*?) diff --git a/Diff/tests/syntax_test_conflict.conflict b/Diff/tests/syntax_test_conflict.conflict deleted file mode 100644 index cb1d2adbe6..0000000000 --- a/Diff/tests/syntax_test_conflict.conflict +++ /dev/null @@ -1,157 +0,0 @@ -\ SYNTAX TEST "Packages/Diff/Conflict.sublime-syntax" - -https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 -<<<<<<< A -\^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup -\^^^^^^ punctuation.section.block.begin.conflict -\ ^ - entity - punctuation -\ ^ entity.name.section.conflict -\ ^ - entity -lines from A -\^^^^^^^^^^^^ meta.block.conflict markup.deleted.conflict - meta.block meta.block -======= -\^^^^^^ meta.block.conflict punctuation.section.block.conflict - meta.block meta.block - markup -lines from B -\^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict ->>>>>>> B -\^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup -\^^^^^^ punctuation.section.block.end.conflict -\ ^ - entity -\ ^ entity.name.section.conflict -\ ^ - entity -context context -\^^^^^^^^^^^^^^^ - meta.block - -<<<<<<< A -lines from A -||||||| B -\^^^^^^^^^ meta.block.conflict - meta.block meta.block - markup -\^^^^^^ punctuation.section.block.conflict -\ ^ - entity - punctuation -\ ^ entity.name.section.conflict -\ ^ - entity -lines from B -\^^^^^^^^^^^^ meta.block.conflict comment.block.conflict - meta.block meta.block - markup -======= -\^^^^^^ meta.block.conflict punctuation.section.block.conflict - meta.block meta.block - markup -> -\ <- meta.block.conflict markup.inserted.conflict - punctuation - invalid -< -\ <- meta.block.conflict markup.inserted.conflict - punctuation - invalid -||||| -\^^^^ meta.block.conflict markup.inserted.conflict invalid.illegal.conflict -lines from C -\^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict ->>>>>>> C -context context -\ <- - meta.block - -<<<<<<< tzu -======= -The Way that can be told of is not the eternal Way; -The name that can be named is not the eternal name. ->>>>>>> tao - -<<<<<<< lao -||||||| tzu -They both may be called deep and profound. -Deeper and more profound, -The door of all subtleties! -======= - - -- The Way of Lao-Tzu, tr. Wing-tsit Chan ->>>>>>> tao - -<<<<<<< lao -======= - - -- The Way of Lao-Tzu, tr. Wing-tsit Chan ->>>>>>> tao - - -https://www.gnu.org/software/diffutils/manual/diffutils.html#Generating-the-Merged-Output-Directly -<<<<<<< tzu -======= -The Way that can be told of is not the eternal Way; -The name that can be named is not the eternal name. ->>>>>>> tao -The Nameless is the origin of Heaven and Earth; -The Named is the mother of all things. -Therefore let there always be non-being, - so we may see their subtlety, -And let there always be being, - so we may see their result. -The two are the same, -But after they are produced, - they have different names. -<<<<<<< lao -||||||| tzu -They both may be called deep and profound. -Deeper and more profound, -The door of all subtleties! -======= - - -- The Way of Lao-Tzu, tr. Wing-tsit Chan ->>>>>>> tao - -If you have questions, please -<<<<<<< HEAD -open an issue -======= -ask your question in IRC. ->>>>>>> branch-a - - -\ https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging -#! /usr/bin/env ruby - -def hello -<<<<<<< ours - puts 'hola world' -||||||| base - puts 'hello world' -======= - puts 'hello mundo' ->>>>>>> theirs -end - -hello() - - -\ https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts -<<<<<<< HEAD:index.html - -======= - ->>>>>>> iss53:index.html - - -\ https://git-scm.com/docs/rerere.html#_nested_conflicts -<<<<<<< HEAD -\^^^^^^^^^^^ meta.block.conflict -\^^^^^^ punctuation.section.block.begin.conflict -\ ^^^^ entity.name.section.conflict -111 -\^^ meta.block.conflict markup.deleted.conflict -======= -\^^^^^^ meta.block.conflict punctuation.section.block.conflict -<<<<<<< HEAD -\^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict meta.block.conflict -\^^^^^^ punctuation.section.block.begin.conflict -\ ^^^^ entity.name.section.conflict -333 -\^^ meta.block.conflict markup.inserted.conflict meta.block.conflict markup.deleted.conflict -======= -\^^^^^^ meta.block.conflict markup.inserted.conflict meta.block.conflict punctuation.section.block.conflict -222 -\^^ meta.block.conflict markup.inserted.conflict meta.block.conflict markup.inserted.conflict ->>>>>>> branch-2 -\^^^^^^^^^^^^^^^ meta.block.conflict markup.inserted.conflict meta.block.conflict -\^^^^^^ punctuation.section.block.end.conflict -\ ^^^^^^^^ entity.name.section.conflict ->>>>>>> branch-3~ -\^^^^^^^^^^^^^^^^ meta.block.conflict -\^^^^^^ punctuation.section.block.end.conflict -\ ^^^^^^^^^ entity.name.section.conflict diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 246f10901f..87a99aeabc 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -403,3 +403,162 @@ Index: added-file +++ added-file (working copy) @@ -0,0 +1 @@ +This is an added file. + + +https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 +<<<<<<< A +\^^^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.begin.diff +\ ^ - entity - punctuation +\ ^ entity.name.section.diff +\ ^ - entity +lines from A +\^^^^^^^^^^^^ meta.block.conflict.diff markup.deleted.diff - meta.block meta.block +======= +\^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.diff +lines from B +\^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff +>>>>>>> B +\^^^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.end.diff +\ ^ - entity +\ ^ entity.name.section.diff +\ ^ - entity +context context +\^^^^^^^^^^^^^^^ - meta.block + +<<<<<<< A +lines from A +||||||| B +\^^^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^ punctuation.section.block.diff +\ ^ - entity - punctuation +\ ^ entity.name.section.diff +\ ^ - entity +lines from B +\^^^^^^^^^^^^ meta.block.conflict.diff comment.block.diff - meta.block meta.block - markup +======= +\^^^^^^ meta.block.conflict.diff punctuation.section.block.diff - meta.block meta.block - markup +> +\ <- meta.block.conflict.diff markup.inserted.diff - punctuation - invalid +< +\ <- meta.block.conflict.diff markup.inserted.diff - punctuation - invalid +||||| +\^^^^ meta.block.conflict.diff markup.inserted.diff invalid.illegal.conflict.diff +lines from C +\^^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff +>>>>>>> C +context context +\ <- - meta.block + +<<<<<<< tzu +======= +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +>>>>>>> tao + +<<<<<<< lao +||||||| tzu +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> tao + +<<<<<<< lao +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> tao + + +https://www.gnu.org/software/diffutils/manual/diffutils.html#Generating-the-Merged-Output-Directly +<<<<<<< tzu +======= +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +>>>>>>> tao +The Nameless is the origin of Heaven and Earth; +The Named is the mother of all things. +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their result. +The two are the same, +But after they are produced, + they have different names. +<<<<<<< lao +||||||| tzu +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> tao + +If you have questions, please +<<<<<<< HEAD +open an issue +======= +ask your question in IRC. +>>>>>>> branch-a + + +\ https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging +#! /usr/bin/env ruby + +def hello +<<<<<<< ours + puts 'hola world' +||||||| base + puts 'hello world' +======= + puts 'hello mundo' +>>>>>>> theirs +end + +hello() + + +\ https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts +<<<<<<< HEAD:index.html + +======= + +>>>>>>> iss53:index.html + + +\ https://git-scm.com/docs/rerere.html#_nested_conflicts +<<<<<<< HEAD +\^^^^^^^^^^^^ meta.block.conflict.diff +\^^^^^^ punctuation.section.block.begin.diff +\ ^^^^ entity.name.section.diff +111 +\^^ meta.block.conflict.diff markup.deleted.diff +======= +\^^^^^^^ meta.block.conflict.diff +\^^^^^^ punctuation.section.block.diff +<<<<<<< HEAD +\^^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict.diff +\^^^^^^ punctuation.section.block.begin.diff +\ ^^^^ entity.name.section.diff +333 +\^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict.diff markup.deleted.diff +======= +\^^^^^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict punctuation.section.block.diff +222 +\^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict markup.inserted.diff +>>>>>>> branch-2 +\^^^^^^^^^^^^^^^ meta.block.conflict markup.inserted.diff meta.block.conflict.diff +\^^^^^^ punctuation.section.block.end.diff +\ ^^^^^^^^ entity.name.section.diff +>>>>>>> branch-3~ +\^^^^^^^^^^^^^^^^ meta.block.conflict.diff +\^^^^^^ punctuation.section.block.end.diff +\ ^^^^^^^^^ entity.name.section.diff From e94d9b7da77e89e60173316e2993be58e27ca0b3 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Wed, 18 Dec 2024 15:15:20 -0500 Subject: [PATCH 117/127] [Diff] Side-by-side diff --- Diff/Diff.sublime-syntax | 27 ++++++++++++++++++++++++++ Diff/tests/syntax_test_diff.diff | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index 4dca8144e6..ea3a8e190d 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -40,6 +40,7 @@ contexts: - include: diff-deltas - include: diff3-edit - include: diff3-normal + - include: side-by-side ###[ HEADERS ]################################################################# @@ -313,6 +314,32 @@ contexts: - match: ^(?:{{conflict_any}}) scope: invalid.illegal.conflict.diff +###[ SIDE-BY-SIDE ]############################################################ + + # https://www.gnu.org/software/diffutils/manual/diffutils.html#Side-by-Side + side-by-side: + - match: ^(.*) (<)$ + captures: + 1: markup.deleted.diff + 2: punctuation.definition.deleted.diff + - match: ^(.*) (\()$ + captures: + 1: comment.line.diff + 2: punctuation.definition.deleted.diff + - match: ^(.*) ([\\|/]) (.*)$ + captures: + 1: markup.changed.diff + 2: punctuation.definition.changed.diff + 3: markup.changed.diff + - match: '^ {4,}(>)(?: (.*))?$' + captures: + 1: punctuation.definition.inserted.diff + 2: markup.inserted.diff + - match: '^ {4,}(\))(?: (.*))?$' + captures: + 1: punctuation.definition.inserted.diff + 2: comment.line.diff + ############################################################################### variables: diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 87a99aeabc..582560a4f3 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -562,3 +562,36 @@ hello() \^^^^^^^^^^^^^^^^ meta.block.conflict.diff \^^^^^^ punctuation.section.block.end.diff \ ^^^^^^^^^ entity.name.section.diff + + +\ https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Side-by-Side +The Way that can be told of is n < +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff +\ ^ punctuation.definition.deleted.diff +The name that can be named is no < +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff +\ ^ punctuation.definition.deleted.diff +The Nameless is the origin of He The Nameless is the origin of He +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - markup +The Named is the mother of all t | The named is the mother of all t +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.diff +\ ^ punctuation.definition.changed.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.changed.diff + > +\ ^ punctuation.definition.inserted.diff +Therefore let there always be no Therefore let there always be no + so we may see their subtlety, so we may see their subtlety, +And let there always be being, And let there always be being, + so we may see their outcome. so we may see their outcome. +The two are the same, The two are the same, +But after they are produced, But after they are produced, + they have different names. they have different names. + > They both may be called deep and +\ ^ punctuation.definition.inserted.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff + > Deeper and more profound, +\ ^ punctuation.definition.inserted.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff + > The door of all subtleties! +\ ^ punctuation.definition.inserted.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.inserted.diff From 15622fc31a18889639f19ee14b2ae7b78ce11b3d Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 19 Dec 2024 09:35:41 +0100 Subject: [PATCH 118/127] [Diff] Scope diff --git line meta.function-call --- Diff/Diff (Basic).sublime-syntax | 2 +- Git Formats/Git Diff.sublime-syntax | 33 +++++++++++--------- Git Formats/tests/syntax_test_git_diff.patch | 17 ++++++++-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Diff/Diff (Basic).sublime-syntax b/Diff/Diff (Basic).sublime-syntax index a3acd7f467..0a83f85151 100644 --- a/Diff/Diff (Basic).sublime-syntax +++ b/Diff/Diff (Basic).sublime-syntax @@ -129,7 +129,7 @@ contexts: path-separators: - match: /|\\ - scope: punctuation.separator.sequence.diff + scope: punctuation.separator.path.diff - match: \B\.\.(?=/|\\) scope: constant.other.path.parent.diff - match: \B\.(?=/|\\) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 7c48b43001..a18bae1d35 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -268,11 +268,12 @@ contexts: # https://git-scm.com/docs/diff-format#generate_patch_text_with_p diffs: - - match: ^(diff) ((--)(?:git|combined|cc)) + - match: ^(diff)( ((--)(?:git|combined|cc))) captures: - 1: variable.function.diff - 2: variable.parameter.diff - 3: punctuation.definition.parameter.diff + 1: meta.function-call.identifier.git variable.function.diff + 2: meta.function-call.arguments.git + 3: variable.parameter.diff + 4: punctuation.definition.parameter.diff push: [diff-header, diff-file-header] # https://git-scm.com/docs/git-format-patch#Documentation/git-format-patch.txt---no-signatureltsignaturegt @@ -290,19 +291,21 @@ contexts: diff-file-header: - meta_scope: meta.toc-list.git + - meta_content_scope: meta.function-call.arguments.git - include: pop-eol # TODO: Quoted file names https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath - - match: \b(a|b|ours|theirs)(/) - captures: - 1: constant.language.diff - 2: punctuation.separator.sequence.diff - push: - - meta_scope: entity.name.diff - - match: \\. - scope: constant.character.escape.git - - match: (?=\s|$) - pop: 1 - - include: path-separators + - match: (?:a|b|ours|theirs)(?=/) + scope: variable.parameter.source.diff + push: diff-file-header-path + + diff-file-header-path: + - meta_include_prototype: false + - meta_content_scope: meta.path.diff entity.name.diff + - match: (?=\s|$) + pop: 1 + - match: \\. + scope: constant.character.escape.git + - include: path-separators diff-header: - meta_prepend: true diff --git a/Git Formats/tests/syntax_test_git_diff.patch b/Git Formats/tests/syntax_test_git_diff.patch index 578f62205a..86359c7f16 100644 --- a/Git Formats/tests/syntax_test_git_diff.patch +++ b/Git Formats/tests/syntax_test_git_diff.patch @@ -79,9 +79,9 @@ Much better, no? \ ^ markup.inserted.diff app/assets/images/logo.jpeg | Bin 0 -> 50966 bytes \^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.diff -\ ^ punctuation.separator.sequence.diff -\ ^ punctuation.separator.sequence.diff -\ ^ punctuation.separator.sequence.diff +\ ^ punctuation.separator.path.diff +\ ^ punctuation.separator.path.diff +\ ^ punctuation.separator.path.diff \ ^ punctuation.separator.sequence.diff \ ^^^ storage.type.diff \ ^ meta.number.integer.decimal.diff constant.numeric.value.diff markup.deleted.diff @@ -98,6 +98,17 @@ Much better, no? \ ^ punctuation.definition.diff diff --git a/Gemfile b/Gemfile +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff meta.toc-list.git +\^^^ meta.function-call.identifier.git variable.function.diff +\ ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.git +\ ^^^^^ variable.parameter.diff +\ ^^ punctuation.definition.parameter.diff +\ ^ variable.parameter.source.diff +\ ^^^^^^^^ meta.path.diff entity.name.diff +\ ^ punctuation.separator.path.diff +\ ^ variable.parameter.source.diff +\ ^^^^^^^^ meta.path.diff entity.name.diff +\ ^ punctuation.separator.path.diff index c661619..989efe8 100644 --- a/Gemfile +++ b/Gemfile From 98fa1f8c2780cf1c6daf4d31288de48af2159a53 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Thu, 19 Dec 2024 12:30:17 -0500 Subject: [PATCH 119/127] [Diff] Update twodot scope --- Git Formats/Git Diff.sublime-syntax | 2 +- Git Formats/tests/syntax_test_git_diff.patch | 4 ++-- Git Formats/tests/syntax_test_git_diff_combined.patch | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index a18bae1d35..21abd3457e 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -524,7 +524,7 @@ contexts: separator-twodot: - match: \.\. - scope: keyword.operator.logical.git + scope: punctuation.separator.range.git file-modes: - match: \b(?:100)?644\b diff --git a/Git Formats/tests/syntax_test_git_diff.patch b/Git Formats/tests/syntax_test_git_diff.patch index 86359c7f16..25ddfa4554 100644 --- a/Git Formats/tests/syntax_test_git_diff.patch +++ b/Git Formats/tests/syntax_test_git_diff.patch @@ -126,7 +126,7 @@ index 0000000000000000000000000000000000000000..064fa38be3ecd426a3c8977ed43df627 \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff \^^^^ keyword.other.diff \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.language.null.git -\ ^^ keyword.operator.logical.git +\ ^^ punctuation.separator.range.git \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git GIT binary patch literal 50966 @@ -149,7 +149,7 @@ index 626bad58a4b2cec0becf93a6473ea19a74752019..7267a0c132111ef91e957a67aaaa5621 \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff \^^^^ keyword.other.diff \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git -\ ^^ keyword.operator.logical.git +\ ^^ punctuation.separator.range.git \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.other.hash.git GIT binary patch delta 946 diff --git a/Git Formats/tests/syntax_test_git_diff_combined.patch b/Git Formats/tests/syntax_test_git_diff_combined.patch index 54ea02d3e4..bdd817c4a8 100644 --- a/Git Formats/tests/syntax_test_git_diff_combined.patch +++ b/Git Formats/tests/syntax_test_git_diff_combined.patch @@ -6,7 +6,7 @@ index fabadb8,cc95eb0..4866510 644 \ ^^^^^^^ constant.other.hash.git \ ^ punctuation.separator.sequence.git \ ^^^^^^^ constant.other.hash.git -\ ^^ keyword.operator.logical.git +\ ^^ punctuation.separator.range.git \ ^^^^^^^ constant.other.hash.git \ ^^^ meta.number.integer.octal.diff constant.numeric.value.diff --- a/describe.c From 39a126ab7511fcb81bfb41a1ba974a6dc2b510df Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Thu, 19 Dec 2024 12:46:00 -0500 Subject: [PATCH 120/127] [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 From 3d631ec7bf5fc3f50716d0cc78261f44c6d5c174 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Thu, 19 Dec 2024 13:38:26 -0500 Subject: [PATCH 121/127] [Diff] Rescope paths --- Git Formats/Git Diff.sublime-syntax | 4 ++-- Git Formats/tests/syntax_test_git_diff.patch | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 72a6f22312..62635099ba 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -230,7 +230,7 @@ contexts: 9: markup.deleted.diff stat-toc-filename: - - meta_content_scope: meta.toc-list.filename.diff entity.name.diff + - meta_content_scope: meta.toc-list.filename.diff meta.path.git string.unquoted.git - match: (?=[ ]+\|) pop: 1 - include: path-separators @@ -302,7 +302,7 @@ contexts: diff-file-header-path: - meta_include_prototype: false - - meta_content_scope: meta.path.diff entity.name.diff + - meta_content_scope: meta.path.diff string.unquoted.git - match: (?=\s|$) pop: 1 - match: \\. diff --git a/Git Formats/tests/syntax_test_git_diff.patch b/Git Formats/tests/syntax_test_git_diff.patch index b07a9d0448..a28abc2716 100644 --- a/Git Formats/tests/syntax_test_git_diff.patch +++ b/Git Formats/tests/syntax_test_git_diff.patch @@ -75,12 +75,12 @@ Much better, no? --- Gemfile | 1 + -\^^^^^^^ entity.name.diff +\^^^^^^^ meta.toc-list.filename.diff meta.path.git string.unquoted.git \ ^ punctuation.separator.sequence.diff \ ^ meta.number.integer.decimal.diff constant.numeric.value.diff \ ^ markup.inserted.diff app/assets/images/logo.jpeg | Bin 0 -> 50966 bytes -\^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.diff +\^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.toc-list.filename.diff meta.path.git string.unquoted.git \ ^ punctuation.separator.path.diff \ ^ punctuation.separator.path.diff \ ^ punctuation.separator.path.diff @@ -106,10 +106,10 @@ diff --git a/Gemfile b/Gemfile \ ^^^^^ variable.parameter.diff \ ^^ punctuation.definition.parameter.diff \ ^ variable.parameter.source.diff -\ ^^^^^^^^ meta.path.diff entity.name.diff +\ ^^^^^^^^ meta.path.diff string.unquoted.git \ ^ punctuation.separator.path.diff \ ^ variable.parameter.source.diff -\ ^^^^^^^^ meta.path.diff entity.name.diff +\ ^^^^^^^^ meta.path.diff string.unquoted.git \ ^ punctuation.separator.path.diff index c661619..989efe8 100644 --- a/Gemfile From 12066ad36fe063d62a64830bdff101b413bd8e48 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Fri, 20 Dec 2024 13:47:46 -0500 Subject: [PATCH 122/127] [Diff] Add missing scopes for copy/move/etc. --- Git Formats/Git Diff.sublime-syntax | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 62635099ba..96eb25f7d5 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -346,16 +346,22 @@ contexts: # copy from # copy to + # move from + # move to # rename from # rename to - - match: ^(?:copy|rename) (from|to) + - match: ^((?:copy|move|rename) (?:from|to))[ \t]+ + captures: + 1: keyword.other.diff push: + - meta_content_scope: meta.path.git string.unquoted.git - include: pop-before-eol - include: path-separators # similarity index # dissimilarity index - match: ^(?:dis)?similarity index + scope: keyword.other.diff push: - include: pop-before-eol - match: (100|[1-9]?[0-9])(%) From 3685f510f7860d09924007ac9fb7ad7d890ad300 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Fri, 20 Dec 2024 13:52:06 -0500 Subject: [PATCH 123/127] [Diff] Git diff file header paths --- Git Formats/Git Diff.sublime-syntax | 11 ++++++++++ Git Formats/tests/syntax_test_git_diff.patch | 22 +++++++++++++++++++ .../tests/syntax_test_git_diff_combined.patch | 6 +++++ 3 files changed, 39 insertions(+) diff --git a/Git Formats/Git Diff.sublime-syntax b/Git Formats/Git Diff.sublime-syntax index 96eb25f7d5..e3ddeeb31b 100644 --- a/Git Formats/Git Diff.sublime-syntax +++ b/Git Formats/Git Diff.sublime-syntax @@ -291,10 +291,21 @@ contexts: signature: - meta_content_scope: comment.block.diff + diff-header-unified-from-file: + - meta_prepend: true + - include: diff-file-header-path-start + + diff-header-unified-to-file: + - meta_prepend: true + - include: diff-file-header-path-start + diff-file-header: - meta_scope: meta.toc-list.git - meta_content_scope: meta.function-call.arguments.git - include: pop-eol + - include: diff-file-header-path-start + + diff-file-header-path-start: # TODO: Quoted file names https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath - match: (?:a|b|ours|theirs)(?=/) scope: variable.parameter.source.diff diff --git a/Git Formats/tests/syntax_test_git_diff.patch b/Git Formats/tests/syntax_test_git_diff.patch index a28abc2716..0cc2394c93 100644 --- a/Git Formats/tests/syntax_test_git_diff.patch +++ b/Git Formats/tests/syntax_test_git_diff.patch @@ -113,8 +113,28 @@ diff --git a/Gemfile b/Gemfile \ ^ punctuation.separator.path.diff index c661619..989efe8 100644 --- a/Gemfile +\^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.from-file meta.header.from-file.diff +\^^ punctuation.definition.from-file.diff +\ ^ variable.parameter.source.diff +\ ^^^^^^^^ meta.path.diff string.unquoted.git +\ ^ punctuation.separator.path.diff +++ b/Gemfile +\^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.to-file meta.header.to-file.diff +\^^ punctuation.definition.to-file.diff +\ ^ variable.parameter.source.diff +\ ^^^^^^^^ meta.path.diff string.unquoted.git +\ ^ punctuation.separator.path.diff @@ -24,6 +24,7 @@ group :development do +\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff +\^^^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff meta.toc-list.hunk.diff +\^ punctuation.definition.range.begin.diff +\ ^ support.function.diff +\ ^ punctuation.separator.sequence.diff +\ ^ support.function.diff +\ ^ punctuation.separator.sequence.diff +\ ^^ punctuation.definition.range.end.diff +\ ^^^^^^^^^^^^^^^^^^^^^^ meta.toc-list.hunk.diff +\ ^^^^^^^^^^^^^^^^^^^^^ entity.name.section.diff gem 'listen', '~> 3.0.5' gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' @@ -124,6 +144,8 @@ index c661619..989efe8 100644 gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/app/assets/images/logo.jpeg b/app/assets/images/logo.jpeg new file mode 100644 +\^^^^^^^^^^^^^^^^^^^ meta.block.header.diff markup.inserted.diff +\ ^^^^^^ meta.number.integer.octal.diff constant.numeric.value.diff index 0000000000000000000000000000000000000000..064fa38be3ecd426a3c8977ed43df627c6f6f229 \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff \^^^^ keyword.other.diff diff --git a/Git Formats/tests/syntax_test_git_diff_combined.patch b/Git Formats/tests/syntax_test_git_diff_combined.patch index bdd817c4a8..1bb07df3aa 100644 --- a/Git Formats/tests/syntax_test_git_diff_combined.patch +++ b/Git Formats/tests/syntax_test_git_diff_combined.patch @@ -12,9 +12,15 @@ index fabadb8,cc95eb0..4866510 644 --- a/describe.c \^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.from-file meta.header.from-file.diff \^^ punctuation.definition.from-file.diff +\ ^ variable.parameter.source.diff +\ ^^^^^^^^^^^ meta.path.diff string.unquoted.git +\ ^ punctuation.separator.path.diff +++ b/describe.c \^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.to-file meta.header.to-file.diff \^^ punctuation.definition.to-file.diff +\ ^ variable.parameter.source.diff +\ ^^^^^^^^^^^ meta.path.diff string.unquoted.git +\ ^ punctuation.separator.path.diff @@@ -98,20 -98,12 +98,20 @@@ \ ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff meta.diff.range.combined meta.range.combined.diff meta.toc-list.hunk.diff return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; From 4ee85d3be7821baf233475ce08b91cc759869e8c Mon Sep 17 00:00:00 2001 From: Michael <2701605+michaelblyons@users.noreply.github.com> Date: Sat, 21 Dec 2024 14:32:26 -0500 Subject: [PATCH 124/127] [Diff] Embed Git Diff from Git Log --- Git Formats/Git Log.sublime-syntax | 52 +----------- Git Formats/tests/syntax_test_git_log | 111 +++++++++++++++++--------- 2 files changed, 75 insertions(+), 88 deletions(-) diff --git a/Git Formats/Git Log.sublime-syntax b/Git Formats/Git Log.sublime-syntax index d773ca5e6e..202806b352 100644 --- a/Git Formats/Git Log.sublime-syntax +++ b/Git Formats/Git Log.sublime-syntax @@ -48,10 +48,9 @@ contexts: - match: ',' scope: punctuation.separator.sequence.git.log - match: (?={{diff_begin}}) - embed: scope:source.shell.bash - escape: $ - - match: (?=^index\s) - push: extended-patch-headers + embed: Git Diff.sublime-syntax#diffs + embed_scope: source.diff.git + escape: (?={{commit_begin}}) commit-header: # All header attributes are mappings of `key: value` format. @@ -72,48 +71,3 @@ contexts: # https://github.com/SublimeTextIssues/Core/issues/2395 - match: ^ push: Git Commit Message.sublime-syntax - - extended-patch-headers: - # https://git-scm.com/docs/git-show#_generating_patch_text_with_p - - meta_scope: meta.diff.header.extended.git.log - - match: ^(index)\s+ - captures: - 1: keyword.context.git.log - push: index - - match: ^((?:new|deleted)\s+file\s+)?(mode)\s+ - captures: - 1: keyword.context.git.log - 2: keyword.context.git.log - push: mode - - match: ^((?:dis)?similarity\s+index)\s+ - captures: - 1: keyword.context.git.log - push: similarity-index - - match: ^((?:copy|move)\s+(?:from|to))\s+ - captures: - 1: keyword.context.git.log - push: copy-or-move - - match: ^ - pop: 1 - embed: scope:source.diff - escape: '{{commit_or_diff_begin}}' - - index: - - include: Git Common.sublime-syntax#commit - - include: mode - - mode: - - include: Git Common.sublime-syntax#eol-pop - - match: ',|\.\.' - scope: punctuation.separator.sequence.git.log - - match: '[0-7]{6}' - scope: meta.number.integer.octal.git.log constant.numeric.value.git.log - - similarity-index: - - include: Git Common.sublime-syntax#eol-pop - - match: \d+ - scope: meta.number.integer.decimal.git.log constant.numeric.value.git.log - - copy-or-move: - - include: Git Common.sublime-syntax#eol-pop - - include: Git Link.sublime-syntax#expect-path diff --git a/Git Formats/tests/syntax_test_git_log b/Git Formats/tests/syntax_test_git_log index ae94ce540c..2ab88e48e7 100644 --- a/Git Formats/tests/syntax_test_git_log +++ b/Git Formats/tests/syntax_test_git_log @@ -82,11 +82,10 @@ Date: Tue Aug 24 13:44:17 2021 -0400 [TypeScript] [TSX] Fix arrow function type parameter tests for TSX. (#2987) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell -# ^ - source.shell -#^^^ source.shell meta.function-call.identifier variable.function +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git +#^^^ meta.function-call.identifier variable.function # ^^ punctuation.definition.parameter -# ^^^ variable.parameter.option +# ^^^ variable.parameter index ae1b1061..c1a585d0 100644 --- a/JavaScript/TypeScript.sublime-syntax #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff meta.diff.header meta.header.from-file @@ -103,48 +102,82 @@ index ae1b1061..c1a585d0 100644 - # branch: - # - ts-old-type-assertion diff --git a/JavaScript/tests/syntax_test_typescript_not_tsx.ts b/JavaScript/tests/syntax_test_typescript_not_tsx.ts -#^^^ source.shell meta.function-call.identifier variable.function +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff meta.toc-list.git +#^^^ meta.function-call.identifier.git variable.function.diff +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.git +# ^^^^^ variable.parameter.diff +# ^^ punctuation.definition.parameter.diff +# ^ variable.parameter.source.diff +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.diff string.unquoted.git +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff +# ^ variable.parameter.source.diff +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.diff string.unquoted.git +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff index c90bfab4,c90bfab4..e9338c70 100644 -#^^^^ keyword.context.git.log -# ^^^^^^^^ constant.other.hash -# ^ punctuation.separator.sequence.git.log -# ^^^^^^^^ constant.other.hash -# ^^ punctuation.separator.sequence.git.log -# ^^^^^^^^ constant.other.hash -# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.extended.git.log -mode 012345,676543..701532 -#^^^ keyword.context.git.log -# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log -# ^ punctuation.separator.sequence.git.log -# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log -# ^^ punctuation.separator.sequence.git.log -# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log -new file mode 012345 -#^^^^^^^^^^^^ keyword.context.git.log -# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log -deleted file mode 012345,676543 -#^^^^^^^^^^^^^^^^ keyword.context.git.log -# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log -# ^ punctuation.separator.sequence.git.log -# ^^^^^^ meta.number.integer.octal.git constant.numeric.value.git.log -similarity index 983489374 -#^^^^^^^^^^^^^^^ keyword.context.git.log -# ^^^^^^^^^ meta.number.integer.decimal.git constant.numeric.value.git.log -dissimilarity index 72637263 -#^^^^^^^^^^^^^^^^^^ keyword.context.git.log -# ^^^^^^^^ meta.number.integer.decimal.git constant.numeric.value.git.log +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff +#^^^^ keyword.other.diff +# ^^^^^^^^ constant.other.hash.git +# ^ punctuation.separator.sequence.git +# ^^^^^^^^ constant.other.hash.git +# ^^ punctuation.separator.range.git +# ^^^^^^^^ constant.other.hash.git +# ^^^^^^ meta.number.integer.octal.diff constant.numeric.value.diff +mode 100644,100755..755 +#^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff +#^^^ keyword.other.diff +# ^^^^^^ meta.number.integer.octal.diff constant.numeric.value.diff +# ^ punctuation.separator.sequence.git +# ^^^^^^ meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff +# ^^ punctuation.separator.range.git +# ^^^ meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff +new file mode 644 +#^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff markup.inserted.diff +# ^^^ meta.number.integer.octal.diff constant.numeric.value.diff +deleted file mode 644,755 +#^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff markup.deleted.diff +# ^^^ meta.number.integer.octal.diff constant.numeric.value.diff +# ^ punctuation.separator.sequence.git +# ^^^ meta.number.integer.octal.diff constant.numeric.value.diff storage.modifier.executable.diff +similarity index 89% +#^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff +#^^^^^^^^^^^^^^^ keyword.other.diff +# ^^^ meta.number.integer.decimal.git +# ^^ constant.numeric.value.git +# ^ constant.numeric.suffix.git +dissimilarity index 4% +#^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff +#^^^^^^^^^^^^^^^^^^ keyword.other.diff +# ^^ meta.number.integer.decimal.git +# ^ constant.numeric.value.git +# ^ constant.numeric.suffix.git copy from JavaScript/tests/syntax_test_typescript_not_tsx.ts -#^^^^^^^^ keyword.context.git.log +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff +#^^^^^^^^ keyword.other.diff # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.git string.unquoted.git +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff move to JavaScript/tests/syntax_test_typescript_not_tsx.ts -#^^^^^^ keyword.context.git.log +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.diff.git meta.block.header.diff +#^^^^^^ keyword.other.diff # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.git string.unquoted.git -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.extended.git.log +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff --- a/JavaScript/tests/syntax_test_typescript_not_tsx.ts -#<- - meta.diff.header.extended +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.from-file meta.header.from-file.diff +#^^ punctuation.definition.from-file.diff +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff +++ b/JavaScript/tests/syntax_test_typescript_not_tsx.ts -#^^ source.diff meta.diff.header meta.header.to-file punctuation.definition.to-file +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.to-file meta.header.to-file.diff +#^^ punctuation.definition.to-file.diff +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff +# ^ punctuation.separator.path.diff @@ -25,3 +25,12 @@ let strLength: number = (someValue).length; // // ^^^^^^^^ meta.assertion - meta.tag From 03488bbcacab7a097837d83425f4efcdc70fe12c Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 9 Jan 2025 18:20:01 +0100 Subject: [PATCH 125/127] [Diff] Improve conflict markers This commit... 1. adds more detailed scopes to conflict markers 2. adds conflicting blocks to symbol list 3. removes some multi-push and lookaheads 4. adds support for indented fenced diff code blocks (allow markers to be preceded by whitespace) --- Diff/Diff.sublime-syntax | 75 ++++++++++------------ Diff/Symbol List - Conflicts.tmPreferences | 18 ++++++ Diff/tests/syntax_test_diff.diff | 22 +++---- Diff/tests/syntax_test_diff.md | 25 ++++++++ 4 files changed, 87 insertions(+), 53 deletions(-) create mode 100644 Diff/Symbol List - Conflicts.tmPreferences create mode 100644 Diff/tests/syntax_test_diff.md diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index ea3a8e190d..d2c1e2603c 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -245,63 +245,54 @@ contexts: # Utility context for other files to use conflict-markers: - - match: ^({{conflict_any}})\s*({{conflict_identifier}})\s*{{eol}} + - match: ^({{conflict_begin}})(?:\s*({{conflict_identifier}}))?{{eol}} + scope: meta.block.conflict.begin.diff + captures: + 1: punctuation.section.block.begin.diff + 2: entity.name.section.diff + - match: ^({{conflict_end}})(?:\s*({{conflict_identifier}}))?{{eol}} + scope: meta.block.conflict.end.diff + captures: + 1: punctuation.section.block.end.diff + 2: entity.name.section.diff + - match: ^({{conflict_base}}|{{conflict_split}})(?:\s*({{conflict_identifier}}))?{{eol}} + scope: meta.block.conflict.separator.diff captures: 1: punctuation.section.block.diff 2: entity.name.section.diff conflicts: - - match: ^(?={{conflict_begin}}) - push: - - conflict - - conflict-marker-start - - conflict: - - meta_scope: meta.block.conflict.diff - - match: '' - pop: 1 - - conflict-marker-start: - - match: '{{conflict_begin}}' - scope: punctuation.section.block.begin.diff - - match: (?:({{conflict_identifier}})\s*)?{{eol}} + - match: ^\s*({{conflict_begin}})(?:\s*({{conflict_identifier}}))?{{eol}} + scope: meta.block.conflict.begin.diff captures: - 1: entity.name.section.diff - set: conflict-deleted-lines + 1: punctuation.section.block.begin.diff + 2: entity.name.section.diff + push: conflict-deleted-lines - conflict-base-marker-start: - - match: '{{conflict_base}}' - scope: punctuation.section.block.diff - - match: (?:({{conflict_identifier}})\s*)?{{eol}} + conflict-deleted-lines: + - meta_content_scope: meta.block.conflict.diff markup.deleted.diff + - match: ^\s*({{conflict_base}})(?:\s*({{conflict_identifier}}))?{{eol}} + scope: meta.block.conflict.separator.diff captures: - 1: entity.name.section.diff + 1: punctuation.section.block.diff + 2: entity.name.section.diff set: conflict-base-lines + - include: conflict-base-lines - conflict-split-marker-start: - - match: '{{conflict_split}}' - scope: punctuation.section.block.diff - - match: (?:({{conflict_identifier}})\s*)?{{eol}} + conflict-base-lines: + - meta_content_scope: meta.block.conflict.diff comment.block.diff + - match: ^\s*({{conflict_split}})(?:\s*({{conflict_identifier}}))?{{eol}} + scope: meta.block.conflict.separator.diff captures: - 1: entity.name.section.diff + 1: punctuation.section.block.diff + 2: entity.name.section.diff set: conflict-new-lines - - conflict-deleted-lines: - - meta_content_scope: markup.deleted.diff - - match: ^(?={{conflict_base}}) - set: conflict-base-marker-start - - match: ^(?={{conflict_split}}) - set: conflict-split-marker-start - - include: invalid-conflict-marker - - conflict-base-lines: - - meta_content_scope: comment.block.diff - - match: ^(?={{conflict_split}}) - set: conflict-split-marker-start - include: invalid-conflict-marker conflict-new-lines: - - meta_content_scope: markup.inserted.diff - - match: ^({{conflict_end}})\s*(?:({{conflict_identifier}})\s*)?{{eol}} + - meta_content_scope: meta.block.conflict.diff markup.inserted.diff + - match: ^\s*({{conflict_end}})(?:\s*({{conflict_identifier}}))?{{eol}} + scope: meta.block.conflict.end.diff captures: 1: punctuation.section.block.end.diff 2: entity.name.section.diff diff --git a/Diff/Symbol List - Conflicts.tmPreferences b/Diff/Symbol List - Conflicts.tmPreferences new file mode 100644 index 0000000000..69593880da --- /dev/null +++ b/Diff/Symbol List - Conflicts.tmPreferences @@ -0,0 +1,18 @@ + + + + scope + meta.block.conflict.begin.diff entity.name.section + settings + + showInSymbolList + 1 + symbolTransformation + s/^/Conflict: / + showInIndexedSymbolList + 0 + showInIndexedReferenceList + 0 + + + diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 582560a4f3..1147da7032 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -407,7 +407,7 @@ Index: added-file https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 <<<<<<< A -\^^^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^^^^ meta.block.conflict.begin.diff - meta.block meta.block - markup \^^^^^^ punctuation.section.block.begin.diff \ ^ - entity - punctuation \ ^ entity.name.section.diff @@ -415,12 +415,12 @@ https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 lines from A \^^^^^^^^^^^^ meta.block.conflict.diff markup.deleted.diff - meta.block meta.block ======= -\^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^^ meta.block.conflict.separator.diff - meta.block meta.block - markup \^^^^^^ punctuation.section.block.diff lines from B \^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff >>>>>>> B -\^^^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^^^^ meta.block.conflict.end.diff - meta.block meta.block - markup \^^^^^^ punctuation.section.block.end.diff \ ^ - entity \ ^ entity.name.section.diff @@ -431,7 +431,7 @@ context context <<<<<<< A lines from A ||||||| B -\^^^^^^^^^ meta.block.conflict.diff - meta.block meta.block - markup +\^^^^^^^^^ meta.block.conflict.separator.diff - meta.block meta.block - markup \^^^^^^ punctuation.section.block.diff \ ^ - entity - punctuation \ ^ entity.name.section.diff @@ -439,7 +439,7 @@ lines from A lines from B \^^^^^^^^^^^^ meta.block.conflict.diff comment.block.diff - meta.block meta.block - markup ======= -\^^^^^^ meta.block.conflict.diff punctuation.section.block.diff - meta.block meta.block - markup +\^^^^^^ meta.block.conflict.separator.diff punctuation.section.block.diff - meta.block meta.block - markup > \ <- meta.block.conflict.diff markup.inserted.diff - punctuation - invalid < @@ -536,30 +536,30 @@ hello() \ https://git-scm.com/docs/rerere.html#_nested_conflicts <<<<<<< HEAD -\^^^^^^^^^^^^ meta.block.conflict.diff +\^^^^^^^^^^^^ meta.block.conflict.begin.diff \^^^^^^ punctuation.section.block.begin.diff \ ^^^^ entity.name.section.diff 111 \^^ meta.block.conflict.diff markup.deleted.diff ======= -\^^^^^^^ meta.block.conflict.diff +\^^^^^^^ meta.block.conflict.separator.diff \^^^^^^ punctuation.section.block.diff <<<<<<< HEAD -\^^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict.diff +\^^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict.begin.diff \^^^^^^ punctuation.section.block.begin.diff \ ^^^^ entity.name.section.diff 333 \^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict.diff markup.deleted.diff ======= -\^^^^^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict punctuation.section.block.diff +\^^^^^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict.separator.diff punctuation.section.block.diff 222 \^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict markup.inserted.diff >>>>>>> branch-2 -\^^^^^^^^^^^^^^^ meta.block.conflict markup.inserted.diff meta.block.conflict.diff +\^^^^^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff meta.block.conflict.end.diff \^^^^^^ punctuation.section.block.end.diff \ ^^^^^^^^ entity.name.section.diff >>>>>>> branch-3~ -\^^^^^^^^^^^^^^^^ meta.block.conflict.diff +\^^^^^^^^^^^^^^^^ meta.block.conflict.end.diff \^^^^^^ punctuation.section.block.end.diff \ ^^^^^^^^^ entity.name.section.diff diff --git a/Diff/tests/syntax_test_diff.md b/Diff/tests/syntax_test_diff.md new file mode 100644 index 0000000000..6427ced6b0 --- /dev/null +++ b/Diff/tests/syntax_test_diff.md @@ -0,0 +1,25 @@ +\ SYNTAX TEST "Packages/Diff/Diff.sublime-syntax" + +1. list item with diff fenced code block + + ```diff + <<<<<<< A + \^^^^^^^^^ meta.block.conflict.begin.diff - meta.block meta.block - markup + \^^^^^^ punctuation.section.block.begin.diff + \ ^ - entity - punctuation + \ ^ entity.name.section.diff + \ ^ - entity + lines from A + \^^^^^^^^^^^^ meta.block.conflict.diff markup.deleted.diff - meta.block meta.block + ======= + \^^^^^^^ meta.block.conflict.separator.diff - meta.block meta.block - markup + \^^^^^^ punctuation.section.block.diff + lines from B + \^^^^^^^^^^^ meta.block.conflict.diff markup.inserted.diff + >>>>>>> B + \^^^^^^^^^ meta.block.conflict.end.diff - meta.block meta.block - markup + \^^^^^^ punctuation.section.block.end.diff + \ ^ - entity + \ ^ entity.name.section.diff + \ ^ - entity + ``` From 3a03a92e3cc6f7e3851458583d5c32359ba2d18c Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Thu, 9 Jan 2025 12:55:36 -0500 Subject: [PATCH 126/127] [Diff] Add some symbol tests Unfortunately, line ranges (which start at BOL) cannot be tested. --- Diff/tests/syntax_test_diff.diff | 19 ++++++++++++++++++- Git Formats/tests/syntax_test_git_diff.patch | 5 ++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Diff/tests/syntax_test_diff.diff b/Diff/tests/syntax_test_diff.diff index 1147da7032..6e1c1299ca 100644 --- a/Diff/tests/syntax_test_diff.diff +++ b/Diff/tests/syntax_test_diff.diff @@ -1,4 +1,4 @@ -\ SYNTAX TEST "Packages/Diff/Diff.sublime-syntax" +\ SYNTAX TEST partial-symbols "Packages/Diff/Diff.sublime-syntax" --- Path to Original File \^^^^^^^^^^^^^^^^^^^^^^^^ meta.diff.header.from-file meta.header.from-file.diff - source.diff.git @@ -103,6 +103,7 @@ Plain Text \ ^^ markup.changed.diff meta.whitespace.trailing.diff Index: lao +\ @@@ local-definition \^^^^^^^^^^ meta.diff.index meta.index.diff \^^^^ meta.mapping.key.diff keyword.other.diff \ ^ punctuation.separator.key-value.diff @@ -340,6 +341,7 @@ Diff3 Edit Format https://www.gnu.org/software/diffutils/manual/diffutils.html#S SVN sample https://svnbook.red-bean.com/en/1.7/svn-book.html#idm10685 Index: deleted-file +\ @@@@@@@@@@@@ local-definition \^^^^^^^^^^^^^^^^^^ meta.mapping.diff meta.diff.index meta.index.diff \^^^^ meta.mapping.key.diff keyword.other.diff \ ^ punctuation.separator.key-value.diff @@ -364,6 +366,7 @@ Index: deleted-file -This file will be deleted. \^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.deleted.diff Index: changed-file +\ @@@@@@@@@@@@ local-definition \^^^^^^^^^^^^^^^^^^ meta.mapping.diff meta.diff.index meta.index.diff \^^^^ meta.mapping.key.diff keyword.other.diff \ ^ punctuation.separator.key-value.diff @@ -390,6 +393,7 @@ Property changes on: changed-file ___________________________________________________________________ \^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.separator.diff punctuation.separator.block.diff Added: propname +\ @@@@@@@@ local-definition \^^^^^^^^^^^^^^ meta.mapping.diff meta.diff.index meta.index.diff \^^^^ meta.mapping.key.diff keyword.other.diff \ ^ punctuation.separator.key-value.diff @@ -398,6 +402,7 @@ Added: propname +propvalue \^^^^^^^^^ markup.inserted.diff Index: added-file +\ @@@@@@@@@@ local-definition =================================================================== --- added-file (revision 0) +++ added-file (working copy) @@ -407,6 +412,7 @@ Index: added-file https://www.gnu.org/software/diffutils/manual/diffutils.html#Marking-Conflicts-1 <<<<<<< A +\ @ local-definition "Conflict: A" \^^^^^^^^^ meta.block.conflict.begin.diff - meta.block meta.block - markup \^^^^^^ punctuation.section.block.begin.diff \ ^ - entity - punctuation @@ -429,6 +435,7 @@ context context \^^^^^^^^^^^^^^^ - meta.block <<<<<<< A +\ @ local-definition "Conflict: A" lines from A ||||||| B \^^^^^^^^^ meta.block.conflict.separator.diff - meta.block meta.block - markup @@ -453,12 +460,14 @@ context context \ <- - meta.block <<<<<<< tzu +\ @@@ local-definition "Conflict: tzu" ======= The Way that can be told of is not the eternal Way; The name that can be named is not the eternal name. >>>>>>> tao <<<<<<< lao +\ @@@ local-definition "Conflict: lao" ||||||| tzu They both may be called deep and profound. Deeper and more profound, @@ -469,6 +478,7 @@ The door of all subtleties! >>>>>>> tao <<<<<<< lao +\ @@@ local-definition "Conflict: lao" ======= -- The Way of Lao-Tzu, tr. Wing-tsit Chan @@ -477,6 +487,7 @@ The door of all subtleties! https://www.gnu.org/software/diffutils/manual/diffutils.html#Generating-the-Merged-Output-Directly <<<<<<< tzu +\ @@@ local-definition "Conflict: tzu" ======= The Way that can be told of is not the eternal Way; The name that can be named is not the eternal name. @@ -491,6 +502,7 @@ The two are the same, But after they are produced, they have different names. <<<<<<< lao +\ @@@ local-definition "Conflict: lao" ||||||| tzu They both may be called deep and profound. Deeper and more profound, @@ -502,6 +514,7 @@ The door of all subtleties! If you have questions, please <<<<<<< HEAD +\ @@@@ local-definition "Conflict: HEAD" open an issue ======= ask your question in IRC. @@ -513,6 +526,7 @@ ask your question in IRC. def hello <<<<<<< ours +\ @@@@ local-definition "Conflict: ours" puts 'hola world' ||||||| base puts 'hello world' @@ -526,6 +540,7 @@ hello() \ https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts <<<<<<< HEAD:index.html +\ @@@@@@@@@@@@@@@ local-definition "Conflict: HEAD:index.html" =======