diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/LexVerilog.cxx | 25 | 
1 files changed, 25 insertions, 0 deletions
| diff --git a/src/LexVerilog.cxx b/src/LexVerilog.cxx index 3fd0fc35c..8b531bb7e 100644 --- a/src/LexVerilog.cxx +++ b/src/LexVerilog.cxx @@ -150,6 +150,22 @@ static bool IsStreamCommentStyle(int style) {  	return style == SCE_V_COMMENT;  } +static bool IsCommentLine(int line, Accessor &styler) { +	int pos = styler.LineStart(line); +	int eolPos = styler.LineStart(line + 1) - 1; +	for (int i = pos; i < eolPos; i++) { +		char ch = styler[i]; +		char chNext = styler.SafeGetCharAt(i + 1); +		int style = styler.StyleAt(i); +		if (ch == '/' && chNext == '/' && +		   (style == SCE_V_COMMENTLINE || style == SCE_V_COMMENTLINEBANG)) { +			return true; +		} else if (!IsASpaceOrTab(ch)) { +			return false; +		} +	} +	return false; +}  // Store both the current line's fold level and the next lines in the  // level store to make it easy to pick up with each increment  // and to make it possible to fiddle the current level for "} else {". @@ -195,6 +211,15 @@ static void FoldNoBoxVerilogDoc(unsigned int startPos, int length, int initStyle  				levelNext--;  			}  		} +		if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) +		{ +			if (!IsCommentLine(lineCurrent - 1, styler) +			    && IsCommentLine(lineCurrent + 1, styler)) +				levelNext++; +			else if (IsCommentLine(lineCurrent - 1, styler) +			         && !IsCommentLine(lineCurrent+1, styler)) +				levelNext--; +		}  		if (foldComment && (style == SCE_V_COMMENTLINE)) {  			if ((ch == '/') && (chNext == '/')) {  				char chNext2 = styler.SafeGetCharAt(i + 2); | 
