[gtksourceview/gtksourceview-4-2] sh.lang: Make "for-command" context end earlier
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gtksourceview-4-2] sh.lang: Make "for-command" context end earlier
- Date: Mon, 28 Oct 2019 18:49:51 +0000 (UTC)
commit 27bf4437912a8bbf097c2f7936a10ee984eaa279
Author: Jeffery To <jeffery to gmail com>
Date: Mon Oct 28 21:35:15 2019 +0800
sh.lang: Make "for-command" context end earlier
This changes the "for-command" context to end earlier, so that it does
not accidentally consume other keywords.
Fixes #40
data/language-specs/sh.lang | 6 +++---
tests/syntax-highlighting/file.sh | 13 +++++++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/data/language-specs/sh.lang b/data/language-specs/sh.lang
index f8e244b7..a53a9b05 100644
--- a/data/language-specs/sh.lang
+++ b/data/language-specs/sh.lang
@@ -218,12 +218,12 @@
<keyword>(?<=\s)\.(?=\s)</keyword>
</context>
- <context id="for-command">
+ <context id="for-command" end-at-line-end="true">
<start>\bfor\b</start>
- <end>\b(in|do)\b</end>
+ <end>(?=\S)</end>
<include>
<context sub-pattern="0" where="start" style-ref="keyword"/>
- <context sub-pattern="0" where="end" style-ref="keyword"/>
+ <context ref="def:line-continue"/>
<context style-ref="variable-definition" once-only="true">
<match>\w+</match>
</context>
diff --git a/tests/syntax-highlighting/file.sh b/tests/syntax-highlighting/file.sh
index 93dfb410..d488950f 100644
--- a/tests/syntax-highlighting/file.sh
+++ b/tests/syntax-highlighting/file.sh
@@ -34,3 +34,16 @@ xxx${x#"*"}xxx
var=val
if var=$(cmd); then some; fi
test -f xxx && var=xxx || var=yyy
+
+for word in hello world
+do
+ echo $word
+done
+
+for arg; do echo $arg; done
+for \
+arg; do echo $arg; done
+
+echo Look for file
+echo Look for; echo Look for
+echo next line
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]