Skip to content

ErrorList add option to disable error recognition #334

@mpheath

Description

@mpheath

Users appear to want to access the ANSI escape function without the error recognition function. Example issue at the Notepad++ repository.

An additional option lexer.errorlist.escape.sequences=2 is the idea to allow this to occur. Currently value 0 is only error styling and 1 is error styling and ANSI escape styling. 2 will be only ANSI escape styling.

I have set lexer.errorlist.value.separate=0 in SciTE as it seems to be the Scintilla default setting that downstream projects may use for testing.

A preview of the 3 options.

Details

Option 0:

Image

Only error styling. Bad for viewing a log file.

Option 1:

Image

Error styling with ANSI escape styling. Bad for viewing a log file.

Option 2:

Image

Only ANSI escape styling. Better for viewing a log file.

The last option could be useful for document formats that view bad with error styling.

Patch view of code:

Details
diff --git a/lexers/LexErrorList.cxx b/lexers/LexErrorList.cxx
index 2198a142..b626adfe 100644
--- a/lexers/LexErrorList.cxx
+++ b/lexers/LexErrorList.cxx
@@ -356,10 +356,11 @@ void ColouriseErrorListLine(
     Sci_PositionU endPos,
     Accessor &styler,
 	bool valueSeparate,
-	bool escapeSequences) {
+	int escapeSequences) {
 	Sci_Position startValue = -1;
 	const Sci_PositionU lengthLine = lineBuffer.length();
-	const int style = RecogniseErrorListLine(lineBuffer.c_str(), lengthLine, startValue);
+	const int style = (escapeSequences == 2) ? SCE_ERR_DEFAULT :
+	                  RecogniseErrorListLine(lineBuffer.c_str(), lengthLine, startValue);
 	if (escapeSequences && strstr(lineBuffer.c_str(), CSI)) {
 		const Sci_Position startPos = endPos - lengthLine;
 		const char *linePortion = lineBuffer.c_str();
@@ -416,7 +417,8 @@ void ColouriseErrorListDoc(Sci_PositionU startPos, Sci_Position length, int, Wor
 
 	// property lexer.errorlist.escape.sequences
 	//	Set to 1 to interpret escape sequences.
-	const bool escapeSequences = styler.GetPropertyInt("lexer.errorlist.escape.sequences") != 0;
+	//	Set to 2 to interpret escape sequences and to disable error recognition.
+	const int escapeSequences = styler.GetPropertyInt("lexer.errorlist.escape.sequences");
 
 	for (Sci_PositionU i = startPos; i < startPos + length; i++) {
 		lineBuffer.push_back(styler[i]);

Files:

ErrorList334.zip

Note:

Commit as Author: mpheath <58158242+mpheath@users.noreply.github.com> if possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    errorlistCaused by the errorlist lexer

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions