Skip to content

Commit

Permalink
[Diff] Scope trailing spaces (#3927)
Browse files Browse the repository at this point in the history
Resolves #1304

This commit scopes trailing spaces `meta.whitespace.trailing`
in inserted/removed/modified lines.
  • Loading branch information
deathaxe authored Feb 18, 2024
1 parent b4decd9 commit c275309
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
17 changes: 10 additions & 7 deletions Diff/Diff.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
45 changes: 25 additions & 20 deletions Diff/syntax_test_diff.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c275309

Please sign in to comment.