From e94d9b7da77e89e60173316e2993be58e27ca0b3 Mon Sep 17 00:00:00 2001 From: Michael Lyons Date: Wed, 18 Dec 2024 15:15:20 -0500 Subject: [PATCH] [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