Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Common] Add git conflict marker highlighting #4047

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ASP/ASP.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ contexts:
- include: root_asp
- match: \n
pop: true
- include: scope:source.diff3#conflicts # merge conflict marker

line_continuation_char:
- match: '\b_'
Expand Down
46 changes: 46 additions & 0 deletions ASP/syntax_test_asp.asp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,52 @@ test = "hello%>
' ^^ punctuation.section.embedded.end.asp
' ^^ punctuation.definition.tag.end.html

<!--
--- Git Conflict Marker Tests
-->

<<<<<<< HEAD
' <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3
' ^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3
' ^ markup.conflict.begin.diff3 - entity - punctuation
' ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3
' ^ markup.conflict.begin.diff3 - entity - punctuation

=======
' <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3
' ^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3
' ^ markup.conflict.separator.diff3 - punctuation

>>>>>>> master
' <- markup.conflict.end.diff3 punctuation.section.conflict.diff3
' ^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3
' ^ markup.conflict.end.diff3 - entity - punctuation
' ^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3
' ^ markup.conflict.end.diff3 - entity - punctuation

<%

<<<<<<< HEAD
' <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3
' ^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3
' ^ markup.conflict.begin.diff3 - entity - punctuation
' ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3
' ^ markup.conflict.begin.diff3 - entity - punctuation

=======
' <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3
' ^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3
' ^ markup.conflict.separator.diff3 - punctuation

>>>>>>> master
' <- markup.conflict.end.diff3 punctuation.section.conflict.diff3
' ^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3
' ^ markup.conflict.end.diff3 - entity - punctuation
' ^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3
' ^ markup.conflict.end.diff3 - entity - punctuation

%>

</body>
'^^^^^^^ meta.tag.structure.any.html
<script type="text/javascript">
Expand Down
4 changes: 4 additions & 0 deletions AppleScript/AppleScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ contexts:
0: punctuation.definition.comment.applescript
pop: true
- include: comments.nested
- include: scope:source.diff3#conflicts # merge conflict marker

comments.nested:
- match: \(\*
captures:
Expand All @@ -554,6 +556,8 @@ contexts:
0: punctuation.definition.comment.applescript
pop: true
- include: comments.nested
- include: scope:source.diff3#conflicts # merge conflict marker

data-structures:
- match: '(\{)'
comment: We cannot necessarily distinguish "records" from "arrays", and so this could be either.
Expand Down
83 changes: 83 additions & 0 deletions AppleScript/tests/syntax_test_applescript.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
-- SYNTAX TEST "Packages/AppleScript/AppleScript.sublime-syntax"

<<<<<<< HEAD
-- <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.begin.diff3 - entity - punctuation
-- ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3
-- ^ markup.conflict.begin.diff3 - entity - punctuation

=======
-- <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.separator.diff3 - punctuation

>>>>>>> foo/bar
-- <- markup.conflict.end.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.end.diff3 - entity - punctuation
-- ^^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3
-- ^ markup.conflict.end.diff3 - entity - punctuation

(* Conflict in block comment
<<<<<<< HEAD
-- <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.begin.diff3 - entity - punctuation
-- ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3
-- ^ markup.conflict.begin.diff3 - entity - punctuation

=======
-- <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.separator.diff3 - punctuation

>>>>>>> master
-- <- markup.conflict.end.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.end.diff3 - entity - punctuation
-- ^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3
-- ^ markup.conflict.end.diff3 - entity - punctuation
*)

{ (* conflict in block *)
<<<<<<< HEAD
-- <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.begin.diff3 - entity - punctuation
-- ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3
-- ^ markup.conflict.begin.diff3 - entity - punctuation

=======
-- <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.separator.diff3 - punctuation

>>>>>>> master
-- <- markup.conflict.end.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.end.diff3 - entity - punctuation
-- ^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3
-- ^ markup.conflict.end.diff3 - entity - punctuation
}

( (* conflict in group *)
<<<<<<< HEAD
-- <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.begin.diff3 - entity - punctuation
-- ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3
-- ^ markup.conflict.begin.diff3 - entity - punctuation

=======
-- <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.separator.diff3 - punctuation

>>>>>>> master
-- <- markup.conflict.end.diff3 punctuation.section.conflict.diff3
--^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3
-- ^ markup.conflict.end.diff3 - entity - punctuation
-- ^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3
-- ^ markup.conflict.end.diff3 - entity - punctuation
)
1 change: 1 addition & 0 deletions Batch File/Batch File.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ contexts:
- match: '{{label_comment}}'
scope: punctuation.definition.comment.dosbatch
push: comment-body
- include: scope:source.diff3#conflicts # merge conflict marker

comment-body:
- meta_scope: comment.line.colon.dosbatch
Expand Down
21 changes: 21 additions & 0 deletions Batch File/tests/syntax_test_batch_file.bat
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,27 @@ ECHO : Not a comment ^
:: <- - comment
::^^^^^^^^^^^^^ - comment

:::: [ Git Conflict Marker Tests ]:::::::::::::::::::::::::::::::::::::::::::::

<<<<<<< HEAD
:: <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3
::^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3
:: ^ markup.conflict.begin.diff3 - entity - punctuation
:: ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3
:: ^ markup.conflict.begin.diff3 - entity - punctuation

=======
:: <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3
::^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3
:: ^ markup.conflict.separator.diff3 - punctuation

>>>>>>> master
:: <- markup.conflict.end.diff3 punctuation.section.conflict.diff3
::^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3
:: ^ markup.conflict.end.diff3 - entity - punctuation
:: ^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3
:: ^ markup.conflict.end.diff3 - entity - punctuation

:::: [ @ Operator ] :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@
Expand Down
1 change: 1 addition & 0 deletions C#/C#.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ contexts:
captures:
1: punctuation.definition.comment.cs
- include: comments_in
- include: scope:source.diff3#conflicts # merge conflict marker

comments_in:
- match: \b(?i:todo|hack|xxx)\b
Expand Down
22 changes: 22 additions & 0 deletions C#/tests/syntax_test_Comments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,25 @@ void dcscmm(Transpose TransA, int m, int n, int k,
double[] c, int offsetc, int ldc);
}
}

class MergeConflict {
<<<<<<< HEAD
// <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3
//^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3
// ^ markup.conflict.begin.diff3 - entity - punctuation
// ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3
// ^ markup.conflict.begin.diff3 - entity - punctuation
void main(int foo) {
=======
// <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3
//^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3
// ^ markup.conflict.separator.diff3 - punctuation
void main(bool bar) {
>>>>>>> master
// <- markup.conflict.end.diff3 punctuation.section.conflict.diff3
//^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3
// ^ markup.conflict.end.diff3 - entity - punctuation
// ^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3
// ^ markup.conflict.end.diff3 - entity - punctuation
}
}
1 change: 1 addition & 0 deletions C++/C.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ contexts:
comments:
- include: block-comments
- include: line-comments
- include: scope:source.diff3#conflicts # merge conflict marker

block-comments:
- match: ^(/\*) =\s*(.*?)\s*= (\*/)$\n?
Expand Down
23 changes: 23 additions & 0 deletions C++/syntax_test_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,29 @@
**/
/* ^^^ invalid.illegal.stray-comment-end.c */

/*
* Merge Conflict Marker Tests
*/

<<<<<<< HEAD
/* <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3 */
/*^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3 */
/* ^ markup.conflict.begin.diff3 - entity - punctuation */
/* ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3 */
/* ^ markup.conflict.begin.diff3 - entity - punctuation */

=======
/* <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3 */
/*^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3 */
/* ^ markup.conflict.separator.diff3 - punctuation */

>>>>>>> master
/* <- markup.conflict.end.diff3 punctuation.section.conflict.diff3 */
/*^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3 */
/* ^ markup.conflict.end.diff3 - entity - punctuation */
/* ^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3 */
/* ^ markup.conflict.end.diff3 - entity - punctuation */

int main(){
int a=5,b=0;
while(a-->0)++b;
Expand Down
23 changes: 23 additions & 0 deletions C++/syntax_test_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,29 @@
**/
/* ^^^ invalid.illegal.stray-comment-end.c */

/*
* Merge Conflict Marker Tests
*/

<<<<<<< HEAD
/* <- markup.conflict.begin.diff3 punctuation.section.conflict.diff3 */
/*^^^^^ markup.conflict.begin.diff3 punctuation.section.conflict.diff3 */
/* ^ markup.conflict.begin.diff3 - entity - punctuation */
/* ^^^^ markup.conflict.begin.diff3 entity.name.section.conflict.diff3 */
/* ^ markup.conflict.begin.diff3 - entity - punctuation */

=======
/* <- markup.conflict.separator.diff3 punctuation.section.conflict.diff3 */
/*^^^^^ markup.conflict.separator.diff3 punctuation.section.conflict.diff3 */
/* ^ markup.conflict.separator.diff3 - punctuation */

>>>>>>> master
/* <- markup.conflict.end.diff3 punctuation.section.conflict.diff3 */
/*^^^^^ markup.conflict.end.diff3 punctuation.section.conflict.diff3 */
/* ^ markup.conflict.end.diff3 - entity - punctuation */
/* ^^^^^^ markup.conflict.end.diff3 entity.name.section.conflict.diff3 */
/* ^ markup.conflict.end.diff3 - entity - punctuation */

Task<int> natural_numbers()
{
int n = 0;
Expand Down
4 changes: 4 additions & 0 deletions CSS/CSS.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ contexts:
- match: /\*+
scope: punctuation.definition.comment.begin.css
push: block-comment-body
- include: scope:source.diff3#conflicts # merge conflict marker

block-comment-body:
- meta_scope: comment.block.css
Expand All @@ -396,6 +397,7 @@ contexts:
- match: ^\s*(\*)(?!/)
captures:
1: punctuation.definition.comment.css
- include: scope:source.diff3#conflicts # merge conflict marker

###[ AT RULES ]################################################################

Expand Down Expand Up @@ -1321,9 +1323,11 @@ contexts:
set: attribute-selector-unquoted-value-content

attribute-selector-unquoted-value-content:
- meta_include_prototype: false
- meta_scope: meta.string.css string.unquoted.css
- match: (?=[\s\]])
pop: 1
- include: string-content

attribute-selector-flag:
- match: \b[iI]{{break}}
Expand Down
File renamed without changes.
File renamed without changes.
Loading