[gtksourceview/gtksourceview-4-6] sh.lang: Fix parameter detection in parameter expansion
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gtksourceview-4-6] sh.lang: Fix parameter detection in parameter expansion
- Date: Fri, 10 Apr 2020 22:02:02 +0000 (UTC)
commit c8b882ded8aa3aaad127c5efcf908bf43cccc8d1
Author: neyfag <11970-neyfag users noreply gitlab gnome org>
Date: Wed Apr 1 00:08:20 2020 +0200
sh.lang: Fix parameter detection in parameter expansion
data/language-specs/sh.lang | 27 +++++++++++++--------------
tests/syntax-highlighting/file.sh | 2 +-
2 files changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/data/language-specs/sh.lang b/data/language-specs/sh.lang
index 88adc473..c62b80f7 100644
--- a/data/language-specs/sh.lang
+++ b/data/language-specs/sh.lang
@@ -436,23 +436,22 @@
<include>
<context sub-pattern="0" where="start" style-ref="variable"/>
<context sub-pattern="0" where="end" style-ref="variable"/>
- <!-- The order of the two following contexts matters -->
- <context id="array-variable" once-only="true">
- <start>([!#])?(\%{identifier})(\[)</start>
- <end>\]</end>
+ <context id="parameter" once-only="true">
+ <start>(?<=\$\{)([!#]?)(\%{identifier}|\%{special-parameter})</start>
+ <end>\%{def:always-match}</end>
<include>
<context sub-pattern="1" where="start" style-ref="keyword"/>
<context sub-pattern="2" where="start" style-ref="variable"/>
- <context sub-pattern="3" where="start" style-ref="keyword"/>
- <context sub-pattern="0" where="end" style-ref="keyword"/>
- <context ref="expansion-nesting"/>
- <context ref="expansion-precedence"/>
- </include>
- </context>
- <context id="simple-variable" once-only="true" style-ref="variable">
- <match>([!#])?\%{identifier}|\%{special-parameter}</match>
- <include>
- <context sub-pattern="1" style-ref="keyword"/>
+ <context id="array-part" once-only="true">
+ <start>\[</start>
+ <end>\]</end>
+ <include>
+ <context sub-pattern="0" where="start" style-ref="keyword"/>
+ <context sub-pattern="0" where="end" style-ref="keyword"/>
+ <context ref="expansion-nesting"/>
+ <context ref="expansion-precedence"/>
+ </include>
+ </context>
</include>
</context>
<!-- Must be included first, to ensure unescaped boundaries -->
diff --git a/tests/syntax-highlighting/file.sh b/tests/syntax-highlighting/file.sh
index 8362978d..90586387 100644
--- a/tests/syntax-highlighting/file.sh
+++ b/tests/syntax-highlighting/file.sh
@@ -10,7 +10,7 @@ xxx${var\
xxx$0000 # One digit parameter
xxx$-xxx xxx$$xxx xxx$@xxx # Special parameters
-xxx${!array[@]}xxx${#array[-1]}xxx${array[0x1+var/2*$(cmd)]}xxx # Arrays
+xxx${!array[@]}xxx${#array[-1]}xxx${array[0x1+var/2*$(cmd)]/a/b}xxx # Arrays
xxx${parameter:-word}xxx${parameter-word}xxx # Use Default Values
xxx${parameter:=word}xxx${parameter=word}xxx # Assign Default Values
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]