diff options
author | Neil <nyamatongwe@gmail.com> | 2015-02-17 14:44:13 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2015-02-17 14:44:13 +1100 |
commit | 0345cc4d8ae095e0722cf764ccddb17141292675 (patch) | |
tree | b611ed44483ade20977e8844fa33ae20a46c89f5 | |
parent | 290d6b8e2b36149e52f6d95ffe193797870de65a (diff) | |
download | scintilla-mirror-0345cc4d8ae095e0722cf764ccddb17141292675.tar.gz |
Bug [#1697]. Allow folding of multiline comments in Ruby.
-rw-r--r-- | lexers/LexRuby.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lexers/LexRuby.cxx b/lexers/LexRuby.cxx index d4c3fad25..a464eab47 100644 --- a/lexers/LexRuby.cxx +++ b/lexers/LexRuby.cxx @@ -1650,6 +1650,19 @@ static bool keywordDoStartsLoop(int pos, return false; } +static bool IsCommentLine(int line, Accessor &styler) { + int pos = styler.LineStart(line); + int eol_pos = styler.LineStart(line + 1) - 1; + for (int i = pos; i < eol_pos; i++) { + char ch = styler[i]; + if (ch == '#') + return true; + else if (ch != ' ' && ch != '\t') + return false; + } + return false; +} + /* * Folding Ruby * @@ -1728,6 +1741,17 @@ static void FoldRbDoc(unsigned int startPos, int length, int initStyle, int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + + /*Mutiline comment patch*/ + if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) { + if (!IsCommentLine(lineCurrent - 1, styler) + && IsCommentLine(lineCurrent + 1, styler)) + levelCurrent++; + else if (IsCommentLine(lineCurrent - 1, styler) + && !IsCommentLine(lineCurrent + 1, styler)) + levelCurrent--; + } + if (style == SCE_RB_COMMENTLINE) { if (foldComment && stylePrev != SCE_RB_COMMENTLINE) { if (chNext == '{') { |