diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-11-26 14:53:22 +0000 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-11-26 14:53:22 +0000 |
commit | 45866afa32ff76f84362a231b036d40dfceb7e68 (patch) | |
tree | 0b4a74ec86b7496c1186399555b88e66d32d1b08 /scintilla/lexers/LexSQL.cxx | |
parent | 55cb29b8cdeded6753c169a47ea9bb47876cfead (diff) | |
download | notepad2-mod-45866afa32ff76f84362a231b036d40dfceb7e68.zip notepad2-mod-45866afa32ff76f84362a231b036d40dfceb7e68.tar.gz notepad2-mod-45866afa32ff76f84362a231b036d40dfceb7e68.tar.bz2 |
update LexSQL
git-svn-id: https://notepad2-mod.googlecode.com/svn/trunk@285 28bd50df-7adb-d945-0439-6e466c6a13cc
Diffstat (limited to 'scintilla/lexers/LexSQL.cxx')
-rw-r--r-- | scintilla/lexers/LexSQL.cxx | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/scintilla/lexers/LexSQL.cxx b/scintilla/lexers/LexSQL.cxx index 3981b7d..aa074b8 100644 --- a/scintilla/lexers/LexSQL.cxx +++ b/scintilla/lexers/LexSQL.cxx @@ -258,6 +258,9 @@ static void FoldSQLDoc(unsigned int startPos, int length, int initStyle, int style = initStyle;
bool endFound = false;
bool isUnfoldingIgnored = false;
+ // this statementFound flag avoids to fold when the statement is on only one line by ignoring ELSE or ELSIF
+ // eg. "IF condition1 THEN ... ELSIF condition2 THEN ... ELSE ... END IF;"
+ bool statementFound = false;
for (unsigned int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
@@ -266,7 +269,7 @@ static void FoldSQLDoc(unsigned int startPos, int length, int initStyle, styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (atEOL || (ch == ';')) {
- // set endFound to false if EOL is reached or ';' is found
+ // set endFound and isUnfoldingIgnored to false if EOL is reached or ';' is found
endFound = false;
isUnfoldingIgnored = false;
}
@@ -329,24 +332,24 @@ static void FoldSQLDoc(unsigned int startPos, int length, int initStyle, // so ignore previous "end" by increment levelNext.
levelNext++;
}
- } else {
- if (!foldOnlyBegin) {
- if (levelCurrent > levelNext) {
- levelCurrent = levelNext;
- }
- levelNext++;
- } else {
- if (levelCurrent > levelNext) {
- // doesn't include this line into the folding block
- // because doesn't hide if, loop or case (eg "end; if" or "end; loop" or "end; case")
- levelCurrent = levelNext;
- }
+ } else if (!foldOnlyBegin) {
+ statementFound = true;
+ if (levelCurrent > levelNext) {
+ levelCurrent = levelNext;
}
+ levelNext++;
+ } else if (levelCurrent > levelNext) {
+ // doesn't include this line into the folding block
+ // because doesn't hide IF, LOOP or CASE (eg "END; IF" or "END; LOOP" or "END; CASE")
+ levelCurrent = levelNext;
}
} else if ((!foldOnlyBegin) && (
- // folding for else & elsif block only if foldAtElse is set.
- foldAtElse && (strcmp(s, "elsif") == 0 || strcmp(s, "else") == 0))) {
- // we are in same case "} else {" in C language
+ // folding for ELSE and ELSIF block only if foldAtElse is set
+ // and IF or CASE aren't on only one line with ELSE or ELSIF (with flag statementFound)
+ foldAtElse && !statementFound && (strcmp(s, "elsif") == 0 || strcmp(s, "else") == 0))) {
+ // prevent also ELSIF and ELSE are on the same line (eg. "ELSIF condition2 THEN ... ELSE ... END IF;")
+ statementFound = true;
+ // we are in same case "} ELSE {" in C language
levelCurrent--;
} else if (strcmp(s, "begin") == 0) {
levelNext++;
@@ -378,6 +381,7 @@ static void FoldSQLDoc(unsigned int startPos, int length, int initStyle, lineCurrent++;
levelCurrent = levelNext;
visibleChars = 0;
+ statementFound = false;
}
if (!isspacechar(ch)) {
visibleChars++;
|