aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaHistory.html4
-rw-r--r--lexers/LexMatlab.cxx33
2 files changed, 28 insertions, 9 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 80d7c8e73..e3d0dce25 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -530,6 +530,10 @@
<a href="http://sourceforge.net/p/scintilla/bugs/1900/">Bug #1900</a>.
</li>
<li>
+ The Matlab lexer requires block comment start and end to be alone on a line.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1902/">Bug #1902</a>.
+ </li>
+ <li>
The Python lexer partly supports f-strings, allows Unicode identifiers, and no longer allows @1 to be a decorator.
<a href="http://sourceforge.net/p/scintilla/bugs/1848/">Bug #1848</a>.
</li>
diff --git a/lexers/LexMatlab.cxx b/lexers/LexMatlab.cxx
index ca5e4d908..45f0b6926 100644
--- a/lexers/LexMatlab.cxx
+++ b/lexers/LexMatlab.cxx
@@ -18,6 +18,9 @@
**
** Changes by John Donoghue 2016/11/15
** - update matlab code folding
+ **
+ ** Changes by John Donoghue 2017/01/18
+ ** - update matlab block comment detection
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
@@ -73,6 +76,15 @@ static int CheckKeywordFoldPoint(char *str) {
return 0;
}
+static bool IsSpaceToEOL(Sci_Position startPos, Accessor &styler) {
+ Sci_Position line = styler.GetLine(startPos);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = startPos; i < eol_pos; i++) {
+ char ch = styler[i];
+ if(!IsASpace(ch)) return false;
+ }
+ return true;
+}
static void ColouriseMatlabOctaveDoc(
Sci_PositionU startPos, Sci_Position length, int initStyle,
@@ -180,7 +192,7 @@ static void ColouriseMatlabOctaveDoc(
}
} else if (sc.state == SCE_MATLAB_COMMENT) {
// end or start of a nested a block comment?
- if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column) {
+ if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column && IsSpaceToEOL(sc.currentPos+2, styler)) {
if(commentDepth > 0) commentDepth --;
curLine = styler.GetLine(sc.currentPos);
@@ -192,7 +204,7 @@ static void ColouriseMatlabOctaveDoc(
transpose = false;
}
}
- else if( IsCommentChar(sc.ch) && sc.chNext == '{' && nonSpaceColumn == column)
+ else if( IsCommentChar(sc.ch) && sc.chNext == '{' && nonSpaceColumn == column && IsSpaceToEOL(sc.currentPos+2, styler))
{
commentDepth ++;
@@ -214,8 +226,11 @@ static void ColouriseMatlabOctaveDoc(
if (sc.state == SCE_MATLAB_DEFAULT) {
if (IsCommentChar(sc.ch)) {
// ncrement depth if we are a block comment
- if(sc.chNext == '{' && nonSpaceColumn == column)
- commentDepth ++;
+ if(sc.chNext == '{' && nonSpaceColumn == column) {
+ if(IsSpaceToEOL(sc.currentPos+2, styler)) {
+ commentDepth ++;
+ }
+ }
curLine = styler.GetLine(sc.currentPos);
styler.SetLineState(curLine, commentDepth);
sc.SetState(SCE_MATLAB_COMMENT);
@@ -284,13 +299,13 @@ static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int
style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
-
+
// a line that starts with a comment
if (style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) {
- // start/end of block comment
- if (chNext == '{')
+ // start/end of block comment
+ if (chNext == '{' && IsSpaceToEOL(i+2, styler))
levelNext ++;
- if (chNext == '}')
+ if (chNext == '}' && IsSpaceToEOL(i+2, styler))
levelNext --;
}
// keyword
@@ -303,7 +318,7 @@ static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int
if (styleNext != SCE_MATLAB_KEYWORD) {
word[wordlen] = '\0';
wordlen = 0;
-
+
levelNext += CheckKeywordFoldPoint(word);
}
}