diff options
| -rw-r--r-- | doc/ScintillaHistory.html | 2 | ||||
| -rw-r--r-- | lexers/LexOthers.cxx | 21 | 
2 files changed, 18 insertions, 5 deletions
| diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index eb5822512..0e316cb44 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -395,6 +395,8 @@  	<td>Gordon Smith</td>  	<td>dimitar</td>  	<td>Sébastien Granjoux</td> +      </tr><tr> +	<td>zenico</td>      </tr>      </table>      <p> diff --git a/lexers/LexOthers.cxx b/lexers/LexOthers.cxx index 5f4eaed2d..259059fd9 100644 --- a/lexers/LexOthers.cxx +++ b/lexers/LexOthers.cxx @@ -500,6 +500,10 @@ static void ColouriseBatchDoc(  	}  } +#define DIFF_BUFFER_START_SIZE 16 +// Note that ColouriseDiffLine analyzes only the first DIFF_BUFFER_START_SIZE +// characters of each line to classify the line. +  static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {  	// It is needed to remember the current state to recognize starting  	// comment lines before the first "diff " or "--- ". If a real @@ -556,20 +560,27 @@ static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {  }  static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { -	char lineBuffer[1024]; +	char lineBuffer[DIFF_BUFFER_START_SIZE];  	styler.StartAt(startPos);  	styler.StartSegment(startPos);  	unsigned int linePos = 0;  	for (unsigned int i = startPos; i < startPos + length; i++) { -		lineBuffer[linePos++] = styler[i]; -		if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) { -			// End of line (or of line buffer) met, colourise it -			lineBuffer[linePos] = '\0'; +		if (AtEOL(styler, i)) { +			if (linePos < DIFF_BUFFER_START_SIZE) { +				lineBuffer[linePos] = 0; +			}  			ColouriseDiffLine(lineBuffer, i, styler);  			linePos = 0; +		} else if (linePos < DIFF_BUFFER_START_SIZE - 1) { +			lineBuffer[linePos++] = styler[i]; +		} else if (linePos == DIFF_BUFFER_START_SIZE - 1) { +			lineBuffer[linePos++] = 0;  		}  	}  	if (linePos > 0) {	// Last line does not have ending characters +		if (linePos < DIFF_BUFFER_START_SIZE) { +			lineBuffer[linePos] = 0; +		}  		ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);  	}  } | 
