diff options
author | Colomban Wendling <unknown> | 2018-09-04 16:00:23 +1000 |
---|---|---|
committer | Colomban Wendling <unknown> | 2018-09-04 16:00:23 +1000 |
commit | 29ad5f44407906fcb298992f9708d8bb2b6472fa (patch) | |
tree | 3ecd7596a90c4f78ee1a56b0b3b96993a24b4a3c | |
parent | deb5b378250069b9da1348f74b46b19a80b66f3d (diff) | |
download | scintilla-mirror-29ad5f44407906fcb298992f9708d8bb2b6472fa.tar.gz |
Backport: Feature [feature-requests:#1144]. Add folding for shell if, do, and case.
Implemented by Zufu Liu and Colomban Wendling.
Backport of changeset 7078:54561e3cbdff.
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | lexers/LexBash.cxx | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index bda608c48..9f94a1744 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -553,6 +553,10 @@ <a href="https://sourceforge.net/p/scintilla/feature-requests/1185/">Feature #1185.</a> </li> <li> + Shell folder folds "if", "do", and "case". + <a href="https://sourceforge.net/p/scintilla/feature-requests/1144/">Feature #1144.</a> + </li> + <li> Fix margin cursor on Cocoa to point more accurately. </li> </ul> diff --git a/lexers/LexBash.cxx b/lexers/LexBash.cxx index 931d1bf47..5bbd563d5 100644 --- a/lexers/LexBash.cxx +++ b/lexers/LexBash.cxx @@ -824,6 +824,8 @@ static void FoldBashDoc(Sci_PositionU startPos, Sci_Position length, int, WordLi int levelCurrent = levelPrev; char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); + char word[8] = { '\0' }; // we're not interested in long words anyway + unsigned int wordlen = 0; for (Sci_PositionU i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -840,6 +842,19 @@ static void FoldBashDoc(Sci_PositionU startPos, Sci_Position length, int, WordLi && !IsCommentLine(lineCurrent + 1, styler)) levelCurrent--; } + if (style == SCE_SH_WORD) { + if ((wordlen + 1) < sizeof(word)) + word[wordlen++] = ch; + if (styleNext != style) { + word[wordlen] = '\0'; + wordlen = 0; + if (strcmp(word, "if") == 0 || strcmp(word, "case") == 0 || strcmp(word, "do") == 0) { + levelCurrent++; + } else if (strcmp(word, "fi") == 0 || strcmp(word, "esac") == 0 || strcmp(word, "done") == 0) { + levelCurrent--; + } + } + } if (style == SCE_SH_OPERATOR) { if (ch == '{') { levelCurrent++; |