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 | 8f6d45ee409147dd9f6224e0a9dff8674a3f304a (patch) | |
| tree | f1dca0bc466cf1d0ac72aa50223d54e1cfcd2a78 | |
| parent | 2603304882a847292fedf38f1edb6d24b99f148e (diff) | |
| download | scintilla-mirror-8f6d45ee409147dd9f6224e0a9dff8674a3f304a.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 == '{') { | 
