From c275309827fc9551873975e92b9a4b2d0b183b32 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 18 Feb 2024 19:16:11 +0100 Subject: [PATCH] [Diff] Scope trailing spaces (#3927) Resolves #1304 This commit scopes trailing spaces `meta.whitespace.trailing` in inserted/removed/modified lines. --- Diff/Diff.sublime-syntax | 17 ++++++++------ Diff/syntax_test_diff.diff | 45 +++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/Diff/Diff.sublime-syntax b/Diff/Diff.sublime-syntax index bb01911225..2856da0f85 100644 --- a/Diff/Diff.sublime-syntax +++ b/Diff/Diff.sublime-syntax @@ -51,20 +51,23 @@ contexts: 2: punctuation.definition.to-file.diff 3: punctuation.definition.to-file.diff 4: punctuation.definition.to-file.diff - - match: ^(((>)( .*)?)|((\+).*))$\n? + - match: ^(?:(>)(?:\ .*?)?|(\+).*?)(\s*?)$\n? scope: markup.inserted.diff captures: - 3: punctuation.definition.inserted.diff - 6: punctuation.definition.inserted.diff - - match: ^(!).*$\n? + 1: punctuation.definition.inserted.diff + 2: punctuation.definition.inserted.diff + 3: meta.whitespace.trailing.diff + - match: ^(!).*?(\s*?)$\n? scope: markup.changed.diff captures: 1: punctuation.definition.changed.diff - - match: ^(((<)( .*)?)|((-).*))$\n? + 2: meta.whitespace.trailing.diff + - match: ^(?:(<)(?:\ .*?)?|(-).*?)(\s*?)$\n? scope: markup.deleted.diff captures: - 3: punctuation.definition.deleted.diff - 6: punctuation.definition.deleted.diff + 1: punctuation.definition.deleted.diff + 2: punctuation.definition.deleted.diff + 3: meta.whitespace.trailing.diff - match: ^Index(:) (.+)$\n? scope: meta.diff.index meta.index.diff captures: diff --git a/Diff/syntax_test_diff.diff b/Diff/syntax_test_diff.diff index d562019112..e2e0550f6f 100644 --- a/Diff/syntax_test_diff.diff +++ b/Diff/syntax_test_diff.diff @@ -70,27 +70,32 @@ Plain Text #^^^^^^^^^ source.diff -+ Addition -# <- punctuation.definition.inserted.diff -# ^^^^^^^^ markup.inserted.diff - -> Addition -# <- punctuation.definition.inserted.diff -# ^^^^^^^^ markup.inserted.diff - -- Deletion -# <- punctuation.definition.deleted.diff -# ^^^^^^^^ markup.deleted.diff - -< Deletion -# <- punctuation.definition.deleted.diff -# ^^^^^^^^ markup.deleted.diff - -! Modified -# <- punctuation.definition.changed.diff -# ^^^^^^^^ markup.changed.diff ++ Addition +# <- markup.inserted.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 + +- Deletion +# <- markup.deleted.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 + +! Modified +# <- markup.changed.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 +# ^ punctuation.separator.key-value.diff # ^^^^^ meta.toc-list.file-name.diff