aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJad Altahan <xviyy@aol.com>2019-01-29 09:18:07 +1100
committerJad Altahan <xviyy@aol.com>2019-01-29 09:18:07 +1100
commit8b99f2cfdd7ed2274afa7bf003850ce4213cbfd3 (patch)
tree5e175beedf3f5eabe9736449cdca8243dcaa1309
parent2f829dbd40a537043774508ed61da9ea92467355 (diff)
downloadscintilla-mirror-8b99f2cfdd7ed2274afa7bf003850ce4213cbfd3.tar.gz
Feature [feature-requests:#1260]. Fix inconsistency with dot styling in Nim.
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--lexers/LexNim.cxx8
-rw-r--r--test/examples/x.nim6
-rw-r--r--test/examples/x.nim.styled6
-rw-r--r--test/lexTests.py3
5 files changed, 25 insertions, 2 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index ec2e9d874..241491425 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -573,6 +573,10 @@
<a href="https://sourceforge.net/p/scintilla/feature-requests/1253/">Feature #1253</a>.
</li>
<li>
+ Fix inconsistency with dot styling in Nim.
+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1260/">Feature #1260</a>.
+ </li>
+ <li>
Fix fold behaviour with comments in nim.
<a href="https://sourceforge.net/p/scintilla/feature-requests/1254/">Feature #1254</a>.
</li>
diff --git a/lexers/LexNim.cxx b/lexers/LexNim.cxx
index 109b3547b..228666b32 100644
--- a/lexers/LexNim.cxx
+++ b/lexers/LexNim.cxx
@@ -424,13 +424,17 @@ void SCI_METHOD LexerNim::Lex(Sci_PositionU startPos, Sci_Position length,
sc.SetState(SCE_NIM_DEFAULT);
break;
case SCE_NIM_IDENTIFIER:
- if (!IsAWordChar(sc.ch)) {
+ if (sc.ch == '.' || !IsAWordChar(sc.ch)) {
char s[100];
sc.GetCurrent(s, sizeof(s));
int style = SCE_NIM_IDENTIFIER;
if (keywords.InList(s) && !funcNameExists) {
- style = SCE_NIM_WORD;
+ // Prevent styling keywords if they are sub-identifiers
+ Sci_Position segStart = styler.GetStartSegment() - 1;
+ if (segStart < 0 || styler.SafeGetCharAt(segStart, '\0') != '.') {
+ style = SCE_NIM_WORD;
+ }
} else if (funcNameExists) {
style = SCE_NIM_FUNCNAME;
}
diff --git a/test/examples/x.nim b/test/examples/x.nim
new file mode 100644
index 000000000..07c9d216f
--- /dev/null
+++ b/test/examples/x.nim
@@ -0,0 +1,6 @@
+# Tests for Nim
+let s = "foobar"
+
+# Feature #1260
+{.ident.}
+stdin.readLine.split.map(parseInt).max.`$`.echo(" is the maximum!")
diff --git a/test/examples/x.nim.styled b/test/examples/x.nim.styled
new file mode 100644
index 000000000..fc1532e60
--- /dev/null
+++ b/test/examples/x.nim.styled
@@ -0,0 +1,6 @@
+{3}# Tests for Nim
+{8}let{0} {16}s{0} {15}={0} {6}"foobar"{0}
+
+{3}# Feature #1260
+{15}{.{16}ident{15}.}{0}
+{16}stdin{15}.{16}readLine{15}.{16}split{15}.{16}map{15}({16}parseInt{15}).{16}max{15}.{11}`$`{15}.{16}echo{15}({6}" is the maximum!"{15}){0}
diff --git a/test/lexTests.py b/test/lexTests.py
index 2dbb1b3ad..92042aa08 100644
--- a/test/lexTests.py
+++ b/test/lexTests.py
@@ -156,6 +156,9 @@ class TestLexers(unittest.TestCase):
def testLua(self):
self.LexExample("x.lua", b"lua", [b"function end"])
+ def testNim(self):
+ self.LexExample("x.nim", b"nim", [b"else end if let"])
+
def testRuby(self):
self.LexExample("x.rb", b"ruby", [b"class def end"])