aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaHistory.html12
-rw-r--r--lexers/LexNim.cxx20
-rw-r--r--test/examples/x.nim8
-rw-r--r--test/examples/x.nim.styled8
4 files changed, 35 insertions, 13 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index a53aed0e9..3f38d74b5 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -553,6 +553,18 @@
</li>
</ul>
<h3>
+ <a href="https://www.scintilla.org/scite415.zip">Release 4.1.5</a>
+ </h3>
+ <ul>
+ <li>
+ Released 7 March 2019.
+ </li>
+ <li>
+ Improve the styling of numbers in Nim.
+ <a href="https://sourceforge.net/p/scintilla/feature-requests/1268/">Feature #1268</a>.
+ </li>
+ <ul>
+ <h3>
<a href="https://www.scintilla.org/scite414.zip">Release 4.1.4</a>
</h3>
<ul>
diff --git a/lexers/LexNim.cxx b/lexers/LexNim.cxx
index 92e1560a9..45a85469c 100644
--- a/lexers/LexNim.cxx
+++ b/lexers/LexNim.cxx
@@ -369,8 +369,8 @@ void SCI_METHOD LexerNim::Lex(Sci_PositionU startPos, Sci_Position length,
sc.Forward(2);
}
} else if (sc.ch == '.') {
- if (sc.chNext == '.') {
- // Pass
+ if (IsADigit(sc.chNext)) {
+ sc.Forward();
} else if (numType <= NumType::Exponent) {
sc.SetState(SCE_NIM_OPERATOR);
break;
@@ -391,7 +391,10 @@ void SCI_METHOD LexerNim::Lex(Sci_PositionU startPos, Sci_Position length,
}
}
} else if (sc.ch == '_') {
- break;
+ // Accept only one underscore between digits
+ if (IsADigit(sc.chNext)) {
+ sc.Forward();
+ }
} else if (numType == NumType::Decimal) {
if (sc.chPrev != '\'' && (sc.ch == 'e' || sc.ch == 'E')) {
numType = NumType::Exponent;
@@ -592,7 +595,7 @@ void SCI_METHOD LexerNim::Lex(Sci_PositionU startPos, Sci_Position length,
if (sc.state == SCE_NIM_DEFAULT) {
// Number
- if (IsADigit(sc.ch) || (IsADigit(sc.chNext) && sc.ch == '.')) {
+ if (IsADigit(sc.ch)) {
sc.SetState(SCE_NIM_NUMBER);
numType = NumType::Decimal;
@@ -703,15 +706,6 @@ void SCI_METHOD LexerNim::Lex(Sci_PositionU startPos, Sci_Position length,
// Operators
else if (strchr("()[]{}:=;-\\/&%$!+<>|^?,.*~@", sc.ch)) {
sc.SetState(SCE_NIM_OPERATOR);
-
- // Ignore decimal coloring in input like: range[0..5]
- if (sc.Match('.', '.')) {
- sc.Forward();
-
- if (sc.chNext == '.') {
- sc.Forward();
- }
- }
}
}
diff --git a/test/examples/x.nim b/test/examples/x.nim
index ac8a274f4..874940d47 100644
--- a/test/examples/x.nim
+++ b/test/examples/x.nim
@@ -18,3 +18,11 @@ let standardTripleLitRawStr = R"""A triple-double raw string\""""
# Style of 'customIdent' is determined by lexer.nim.raw.strings.highlight.ident. 16 if false, 6 or 10 if true
let customDoubleLitRawStr = customIdent"A string\"
let customTripleLitRawStr = customIdent"""A triple-double raw string\""""
+
+# Feature #1268
+10_000
+10__000
+10_
+1....5
+1.ident
+1._ident
diff --git a/test/examples/x.nim.styled b/test/examples/x.nim.styled
index 2753d005e..3a05c04b8 100644
--- a/test/examples/x.nim.styled
+++ b/test/examples/x.nim.styled
@@ -18,3 +18,11 @@
{3}# Style of 'customIdent' is determined by lexer.nim.raw.strings.highlight.ident. 16 if false, 6 or 10 if true
{8}let{0} {16}customDoubleLitRawStr{0} {15}={0} {16}customIdent{6}"A string\"{0}
{8}let{0} {16}customTripleLitRawStr{0} {15}={0} {16}customIdent{10}"""A triple-double raw string\""""{0}
+
+{3}# Feature #1268
+{5}10_000{0}
+{5}10{16}__000{0}
+{5}10{16}_{0}
+{5}1{15}....{5}5{0}
+{5}1{15}.{16}ident{0}
+{5}1{15}.{16}_ident{0}