Merge branch '3487_syntax_highlighting_fixes'

* 3487_syntax_highlighting_fixes:
  mcedit: fixed syntax highlighting bug in .c and .cxx syntax scripts
  Ticket #3487: mcedit: fixed invalid syntax highlighting
This commit is contained in:
Andrew Borodin 2019-02-09 10:42:58 +03:00
commit e2b8a50cea
3 changed files with 12 additions and 2 deletions

View File

@ -36,7 +36,7 @@ context default
keyword whole inline yellow keyword whole inline yellow
keyword whole wchar_t yellow keyword whole wchar_t yellow
keyword whole ... yellow keyword whole ... yellow
keyword whole linestart \{\s\t\}\[\s\t\]#*\n brightmagenta keyword linestart \{\s\t\}\[\s\t\]#*\n brightmagenta
keyword whole \[\s\t\]default yellow keyword whole \[\s\t\]default yellow
keyword whole linestart \[\s\t\]\{ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz\}\[0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz\]: cyan keyword whole linestart \[\s\t\]\{ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz\}\[0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz\]: cyan

View File

@ -62,7 +62,7 @@ context default
keyword whole using yellow keyword whole using yellow
keyword whole wchar_t yellow keyword whole wchar_t yellow
keyword whole ... yellow keyword whole ... yellow
keyword whole linestart \{\s\t\}\[\s\t\]#*\n brightmagenta keyword linestart \{\s\t\}\[\s\t\]#*\n brightmagenta
keyword /\* brown keyword /\* brown
keyword \*/ brown keyword \*/ brown

View File

@ -446,6 +446,16 @@ apply_rules_going_right (WEdit * edit, off_t i)
k->whole_word_chars_right, k->line_start); k->whole_word_chars_right, k->line_start);
if (e > 0) if (e > 0)
{ {
/* when both context and keyword terminate with a newline,
the context overflows to the next line and colorizes it incorrectly */
if (_rule._context != 0 && k->keyword[strlen (k->keyword) - 1] == '\n')
{
r = CONTEXT_RULE (g_ptr_array_index (edit->rules, _rule._context));
if (r->right != NULL && r->right[0] != '\0'
&& r->right[strlen (r->right) - 1] == '\n' && e > i + 1)
e--;
}
end = e; end = e;
_rule.end = e; _rule.end = e;
_rule.keyword = count; _rule.keyword = count;