[gtksourceview] sh.lang: Fix a bug and improve "parameter-expansion" context
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] sh.lang: Fix a bug and improve "parameter-expansion" context
- Date: Wed, 13 Nov 2019 17:41:14 +0000 (UTC)
commit c0ad2bfdb91225d456ee79ee55b8691a448d1e22
Author: neyfag <11970-neyfag users noreply gitlab gnome org>
Date: Tue Nov 12 22:16:24 2019 +0100
sh.lang: Fix a bug and improve "parameter-expansion" context
data/language-specs/sh.lang | 17 ++++++++++++-----
tests/syntax-highlighting/file.sh | 11 +++++++----
2 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/data/language-specs/sh.lang b/data/language-specs/sh.lang
index 9590369d..1d073038 100644
--- a/data/language-specs/sh.lang
+++ b/data/language-specs/sh.lang
@@ -180,13 +180,20 @@
</context>
<context id="short-parameter-expansion" style-ref="variable">
- <match>\$([!@?*#\$0-9]|\%{identifier})</match>
+ <match>\$([-!@?*#\$0-9]|\%{identifier})</match>
</context>
- <context id="parameter-expansion" style-ref="variable">
- <start>\$\{</start>
+ <context id="parameter-expansion" style-ref="def:statement" style-inside="true">
+ <start extended="true">
+ \$\{ (
+ [-@?*\$0-9]
+ | [!#]? ( \%{identifier} (\[ ([@*]|-?[0-9]+) \])? )?
+ )</start>
<end>\}</end>
<include>
+ <context sub-pattern="0" where="start" style-ref="variable"/>
+ <context sub-pattern="0" where="end" style-ref="variable"/>
+ <context ref="def:escape"/>
<context ref="single-quoted-string"/>
<context ref="double-quoted-string"/>
<context ref="variable"/>
@@ -346,8 +353,8 @@
</context>
<context id="common-command" style-ref="common-command">
- <prefix>(?<![\w\-\.])</prefix>
- <suffix>(?![\w\-\.])</suffix>
+ <prefix>(?<=\%{unescaped-space}|\%[)</prefix>
+ <suffix>(?=\s|\%])</suffix>
<keyword>ar</keyword>
<keyword>awk</keyword>
<keyword>basename</keyword>
diff --git a/tests/syntax-highlighting/file.sh b/tests/syntax-highlighting/file.sh
index 68a35b26..fe52c1e4 100644
--- a/tests/syntax-highlighting/file.sh
+++ b/tests/syntax-highlighting/file.sh
@@ -3,10 +3,12 @@ echo "Hi there!"
# Parameter Expansion
-xxx${xxx}xxx # parameter in braces
-xxx${"{"}xxx xxx${"}"}xxx # brace in quoted string
+xxx${xxx}xxx # Parameter in braces
+xxx${var/\"}xxx xxx${var/\}}xxx # Escaped characters
-xxx$0000 # one digit parameter
+xxx$0000 # One digit parameter
+xxx$-xxx xxx$$xxx xxx$@xxx # Special parameters
+xxx${array[@]}xxx xxx${!array[@]}xxx xxx${array[-1]}xxx # Arrays
xxx${parameter:-word}xxx${parameter-word}xxx # Use Default Values
xxx${parameter:=word}xxx${parameter=word}xxx # Assign Default Values
@@ -15,6 +17,7 @@ xxx${parameter:?}xxx${parameter?}xxx # Indicate Error if Null or Unset
xxx${parameter:+word}xxx${parameter+word}xxx # Use Alternative Value
xxx${#parameter}xxx # String Length
+xxx${!parameter}xxx # Names matching prefix
xxx${parameter%word}xxx # Remove Smallest Suffix Pattern
xxx${parameter%%word}xxx # Remove Largest Suffix Pattern
xxx${parameter#word}xxx # Remove Smallest Prefix Pattern
@@ -36,7 +39,7 @@ if var=$(cmd); then some; fi
test -f xxx && var=xxx || var=yyy
echo text | var=xxx cmd & var=yyy
declare -i '-r' "-x" var1=val1 var2=$val1 var3=`cmd1` \
- var4=$(cmd2) var5=xxx\ yyy var6 #comment
+ var4=$(cmd2) var5=xxx\ yyy var6 # Comment
var+=xxx; (var=yyy); { var=zzz; }
case $1 in
item) var=xxx;;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]