aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohn Donoghue <john.donoghue@ieee.org>2017-06-29 07:54:05 -0400
committerJohn Donoghue <john.donoghue@ieee.org>2017-06-29 07:54:05 -0400
commit31134f985d706f10c79aac22550670961ffeb510 (patch)
treee0c3da0106ede92221c7d6a6e7492fd4980eeb9b
parent0da32f46338d24a5648c30110024227fe09baaad (diff)
downloadscintilla-mirror-31134f985d706f10c79aac22550670961ffeb510.tar.gz
Backport: Bug [#1951]. matlab lexer - dont use 'end' as a keyword when used as a index.
(ColouriseMatlabOctaveDoc) - set end as a number if within brackets ()[]{} that would allow end as an index rather than a keyword. Backport of changeset 6332:15f61ea20276.
-rw-r--r--doc/ScintillaHistory.html5
-rw-r--r--lexers/LexMatlab.cxx13
2 files changed, 18 insertions, 0 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 934c23cd2..383052e84 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -539,6 +539,11 @@
An SCN_AUTOCSELECTIONCHANGE notification is sent when items are highlighted in an autocompletion or user list.
</li>
<li>
+ The Matlab lexer treats 'end' as a number rather than a keyword when used as a index.
+ This also stops incorrect folding.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1951/">Bug #1951</a>.
+ </li>
+ <li>
The Rust lexer recognizes 'usize' numeric literal suffixes.
<a href="http://sourceforge.net/p/scintilla/bugs/1919/">Bug #1919</a>.
</li>
diff --git a/lexers/LexMatlab.cxx b/lexers/LexMatlab.cxx
index 45f0b6926..a0e3ea937 100644
--- a/lexers/LexMatlab.cxx
+++ b/lexers/LexMatlab.cxx
@@ -100,6 +100,9 @@ static void ColouriseMatlabOctaveDoc(
// of a string
bool transpose = false;
+ // count of brackets as boolean for when end could be an operator not a keyword
+ int allow_end_op = 0;
+
// approximate position of first non space character in a line
int nonSpaceColumn = -1;
// approximate column position of the current character in a line
@@ -153,7 +156,11 @@ static void ColouriseMatlabOctaveDoc(
if (!isalnum(sc.ch) && sc.ch != '_') {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
+
if (keywords.InList(s)) {
+ if (strcmp ("end", s) == 0 && allow_end_op) {
+ sc.ChangeState(SCE_MATLAB_NUMBER);
+ }
sc.SetState(SCE_MATLAB_DEFAULT);
transpose = false;
} else {
@@ -253,6 +260,12 @@ static void ColouriseMatlabOctaveDoc(
} else if (isalpha(sc.ch)) {
sc.SetState(SCE_MATLAB_KEYWORD);
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '\\') {
+ if (sc.ch == '(' || sc.ch == '[' || sc.ch == '{') {
+ allow_end_op ++;
+ } else if ((sc.ch == ')' || sc.ch == ']' || sc.ch == '}') && (allow_end_op > 0)) {
+ allow_end_op --;
+ }
+
if (sc.ch == ')' || sc.ch == ']' || sc.ch == '}') {
transpose = true;
} else {