Mercurial > mxe-octave
comparison src/qscintilla-3-matlab-block-comment.patch @ 4340:c202df909032
sqcintilla: add patch for proper matlab block comment detection (Bug #50060)
* src/qscintilla-3-matlab-block-comment.patch: new patc file
* dist-files.mk: added qscintilla-3-matlab-block-comment.patch
author | John D |
---|---|
date | Thu, 19 Jan 2017 07:57:27 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4339:07671a76e291 | 4340:c202df909032 |
---|---|
1 diff -ur QScintilla_gpl-2.9.3.orig/lexers/LexMatlab.cpp QScintilla_gpl-2.9.3/lexers/LexMatlab.cpp | |
2 --- QScintilla_gpl-2.9.3.orig/lexers/LexMatlab.cpp 2017-01-18 08:06:39.577378613 -0500 | |
3 +++ QScintilla_gpl-2.9.3/lexers/LexMatlab.cpp 2017-01-18 08:21:30.775353161 -0500 | |
4 @@ -71,6 +71,16 @@ | |
5 return -1; | |
6 return 0; | |
7 } | |
8 + | |
9 +static bool IsSpaceToEOL(unsigned int startPos, Accessor &styler) { | |
10 + int line = styler.GetLine(startPos); | |
11 + unsigned int eol_pos = styler.LineStart(line + 1) - 1; | |
12 + for (unsigned int i = startPos; i < eol_pos; i++) { | |
13 + char ch = styler[i]; | |
14 + if(!IsASpace(ch)) return false; | |
15 + } | |
16 + return true; | |
17 +} | |
18 | |
19 static void ColouriseMatlabOctaveDoc( | |
20 unsigned int startPos, int length, int initStyle, | |
21 @@ -178,7 +188,7 @@ | |
22 } | |
23 } else if (sc.state == SCE_MATLAB_COMMENT) { | |
24 // end or start of a nested a block comment? | |
25 - if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column) { | |
26 + if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column && IsSpaceToEOL(sc.currentPos+2, styler)) { | |
27 if(commentDepth > 0) commentDepth --; | |
28 | |
29 curLine = styler.GetLine(sc.currentPos); | |
30 @@ -190,7 +200,7 @@ | |
31 transpose = false; | |
32 } | |
33 } | |
34 - else if( IsCommentChar(sc.ch) && sc.chNext == '{' && nonSpaceColumn == column) | |
35 + else if( IsCommentChar(sc.ch) && sc.chNext == '{' && nonSpaceColumn == column && IsSpaceToEOL(sc.currentPos+2, styler)) | |
36 { | |
37 commentDepth ++; | |
38 | |
39 @@ -211,9 +221,12 @@ | |
40 // check start of a new state | |
41 if (sc.state == SCE_MATLAB_DEFAULT) { | |
42 if (IsCommentChar(sc.ch)) { | |
43 - // ncrement depth if we are a block comment | |
44 - if(sc.chNext == '{' && nonSpaceColumn == column) | |
45 - commentDepth ++; | |
46 + // Increment depth if we are a block comment | |
47 + if(sc.chNext == '{' && nonSpaceColumn == column) { | |
48 + if(IsSpaceToEOL(sc.currentPos+2, styler)) { | |
49 + commentDepth ++; | |
50 + } | |
51 + } | |
52 curLine = styler.GetLine(sc.currentPos); | |
53 styler.SetLineState(curLine, commentDepth); | |
54 sc.SetState(SCE_MATLAB_COMMENT); | |
55 @@ -287,9 +300,9 @@ | |
56 // a line that starts with a comment | |
57 if (style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) { | |
58 // start/end of block comment | |
59 - if (chNext == '{') | |
60 + if (chNext == '{' && IsSpaceToEOL(i+2, styler)) | |
61 levelNext ++; | |
62 - if (chNext == '}') | |
63 + if (chNext == '}' && IsSpaceToEOL(i+2, styler)) | |
64 levelNext --; | |
65 } | |
66 // keyword |