Fix for keyword highlighting on the context boundary



Hello, Paul!

I have committed a patch for Midnight Commander that may be of some
interest for you as the maintainer of Cooledit.  It fixes a bug in the
syntax highlighting engine, and I expect that Midnight Commander will
soon use syntax highlighting rules that require this bug to be fixed.

It would be nice if MC and Cooledit still could share syntax rules, so 
please apply this patch.  I have tested it with Cooledit 3.17.5.

The problem is that a keyword starting at the beginning of a context is 
not highlighted.  Even though the new context starts, the keyword rule is 
not rechecked, despite what the comment in the code claims.

Here's an example.  I tried to use this in the rules for ChangeLog:

context linestart \t \n\n 
    keyword whole \t\* brightcyan/17 

This is supposed to highlight every "*" after Tab.  However, the first "*" 
in a group of indented lines is not highlighted due to the bug.

ChangeLog:
	* syntax.c (apply_rules_going_right): Recheck keyword rules when 
	a keyword is found on the left border of a context. 

=========================
--- syntax.c
+++ syntax.c
@@ -320,8 +320,10 @@ static inline struct syntax_rule apply_r
 			_rule.border = RULE_ON_LEFT_BORDER;
 			_rule._context = count;
 			if (!r->between_delimiters)
-			    if (!_rule.keyword)
+			    if (!_rule.keyword) {
 				_rule.context = count;
+				contextchanged = 1;
+			    }
 			break;
 		    }
 		}
=========================

By the way, please feel free to take rules from MC for Cooledit.  Some
files may need adding colors for Cooledit, but you could implement default
colors based on their MC names, i.e. "yellow" or "yellow/" would mean
"yellow/24" for Cooledit.

-- 
Regards,
Pavel Roskin




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]