[gtksourceview: 3/4] scss.lang, less.lang: Fix single-line comments not ignored
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview: 3/4] scss.lang, less.lang: Fix single-line comments not ignored
- Date: Tue, 21 Jan 2020 00:26:01 +0000 (UTC)
commit 228eaabedec96f3cf9debeded78cc0165d8d0c73
Author: Jeffery To <jeffery to gmail com>
Date: Tue Jan 21 03:41:59 2020 +0800
scss.lang, less.lang: Fix single-line comments not ignored
This fixes the declaration/selector test to ignore content inside of
single-line comments.
data/language-specs/less.lang | 10 +++++++---
data/language-specs/scss.lang | 13 +++++++++----
tests/syntax-highlighting/file.less | 5 +++++
tests/syntax-highlighting/file.scss | 5 +++++
4 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/data/language-specs/less.lang b/data/language-specs/less.lang
index 2f483944..bedfd061 100644
--- a/data/language-specs/less.lang
+++ b/data/language-specs/less.lang
@@ -398,8 +398,8 @@
<context id="less-declaration-value">
<start extended="true">
(?(DEFINE)
- (?<escape_comment_start> (?: \\ /\* )+ )
- (?<escape> (?: \\ . )+ )
+ (?<escape_comment_start> (?: \\ /[/*] )+ )
+ (?<escape> (?: \\ . )+ )
(?<escape_not_interpolation_start> (?: \\ (?! @{ ) . )+ )
@@ -407,12 +407,14 @@
(?: (?: @ (?! { ) )+ | (?: (?<! @ ) { )+ )
)
(?<comment_start_chars>
- (?: (?: / (?! \* ) )+ | (?: (?<! / ) \* )+ )
+ (?: (?: (?<! / ) / (?! [/*] ) )+ | (?: (?<! / ) \* )+ )
)
(?<comment_end_chars>
(?: (?: \* (?! / ) )+ | (?: (?<! \* ) / )+ )
)
+ (?<single_line_comment> // .* )
+
(?<interpolation> # recursive subpattern to find matching braces
@{
(?:
@@ -440,6 +442,7 @@
)+
) |
(?&parentheses) |
+ (?&single_line_comment) |
(?&multiline_comment) |
(?&double_quote_string) |
(?&single_quote_string)
@@ -513,6 +516,7 @@
)+
) |
(?&parentheses) |
+ (?&single_line_comment) |
(?&multiline_comment) |
(?&double_quote_string) |
(?&single_quote_string)
diff --git a/data/language-specs/scss.lang b/data/language-specs/scss.lang
index 63ffa8e9..5d7ee953 100644
--- a/data/language-specs/scss.lang
+++ b/data/language-specs/scss.lang
@@ -409,20 +409,22 @@
<context id="scss-declaration-value">
<start extended="true">
(?(DEFINE)
- (?<escape_interpolation_start> (?: \\ \#{ )+ )
- (?<escape_comment_start> (?: \\ /\* )+ )
- (?<escape> (?: \\ . )+ )
+ (?<escape_interpolation_start> (?: \\ \#{ )+ )
+ (?<escape_comment_start> (?: \\ /[/*] )+ )
+ (?<escape> (?: \\ . )+ )
(?<interpolation_start_chars>
(?: (?: \# (?! { ) )+ | (?: (?<! \# ) { )+ )
)
(?<comment_start_chars>
- (?: (?: / (?! \* ) )+ | (?: (?<! / ) \* )+ )
+ (?: (?: (?<! / ) / (?! [/*] ) )+ | (?: (?<! / ) \* )+ )
)
(?<comment_end_chars>
(?: (?: \* (?! / ) )+ | (?: (?<! \* ) / )+ )
)
+ (?<single_line_comment> // .* )
+
(?<interpolation> # recursive subpattern to find matching braces
\#{
(?:
@@ -438,6 +440,7 @@
) |
(?&interpolation) |
(?&parentheses) |
+ (?&single_line_comment) |
(?&multiline_comment) |
(?&double_quote_string) |
(?&single_quote_string)
@@ -460,6 +463,7 @@
) |
(?&interpolation) |
(?&parentheses) |
+ (?&single_line_comment) |
(?&multiline_comment) |
(?&double_quote_string) |
(?&single_quote_string)
@@ -539,6 +543,7 @@
) |
(?&interpolation) |
(?&parentheses) |
+ (?&single_line_comment) |
(?&multiline_comment) |
(?&double_quote_string) |
(?&single_quote_string)
diff --git a/tests/syntax-highlighting/file.less b/tests/syntax-highlighting/file.less
index 594fcaba..a6f9d486 100644
--- a/tests/syntax-highlighting/file.less
+++ b/tests/syntax-highlighting/file.less
@@ -425,6 +425,8 @@ div {
// incorrectly highlighted declarations
display:block
;
+ display:block // {
+ ;
// selectors
input:focus { opacity: 0.5; }
@@ -450,6 +452,9 @@ div {
a:focus[id=' ] \' \; ; '] { color: blue; }
a:focus[id=' @{var} '] { color: blue; }
+
+ a:focus // ;
+ { color: blue; }
}
diff --git a/tests/syntax-highlighting/file.scss b/tests/syntax-highlighting/file.scss
index 695a771a..a764ae45 100644
--- a/tests/syntax-highlighting/file.scss
+++ b/tests/syntax-highlighting/file.scss
@@ -457,6 +457,8 @@ div {
// incorrectly highlighted declarations
display:block
;
+ display:block // {
+ ;
// selectors
input:focus { opacity: 0.5; }
@@ -488,6 +490,9 @@ div {
a:focus[id=' ] \' \; ; '] { color: blue; }
a:focus[id=' #{ \' '' ';' } '] { color: blue; }
+
+ a:focus // ;
+ { color: blue; }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]