Skip to content

Commit ff01513

Browse files
sohomdatta1gitster
authored andcommitted
userdiff: expand detected chunk headers for css
The regex used for the CSS builtin diff driver in git is only able to show chunk headers for lines that start with a number, a letter or an underscore. However, the regex fails to detect classes (starts with a .), ids (starts with a #), :root and attribute-value based selectors (for example [class*="col-"]), as well as @BASED block-level statements like @page,@Keyframes and @media since all of them, start with a special character. Allow the selectors and block level statements to begin with these special characters. Signed-off-by: Sohom Datta <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d98273b commit ff01513

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

t/t4018/css-attribute-value-selector

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[class*="RIGHT"] {
2+
background : #000;
3+
border : 10px ChangeMe #C6C6C6;
4+
}

t/t4018/css-block-level-@-statements

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@keyframes RIGHT {
2+
from {
3+
background : #000;
4+
border : 10px ChangeMe #C6C6C6;
5+
}
6+
to {
7+
background : #fff;
8+
border : 10px solid #C6C6C6;
9+
}
10+
}

t/t4018/css-class-selector

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.RIGHT {
2+
background : #000;
3+
border : 10px ChangeMe #C6C6C6;
4+
}

t/t4018/css-id-selector

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#RIGHT {
2+
background : #000;
3+
border : 10px ChangeMe #C6C6C6;
4+
}

t/t4018/css-root-selector

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:RIGHT {
2+
background : #000;
3+
border : 10px ChangeMe #C6C6C6;
4+
}

userdiff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ PATTERNS("csharp",
200200
"|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
201201
IPATTERN("css",
202202
"![:;][[:space:]]*$\n"
203-
"^[_a-z0-9].*$",
203+
"^[:[@.#]?[_a-z0-9].*$",
204204
/* -- */
205205
/*
206206
* This regex comes from W3C CSS specs. Should theoretically also

0 commit comments

Comments
 (0)