Bug 497097 - Bracket matching is broken if section patterns are followed by a block pattern in grammar
Summary: Bracket matching is broken if section patterns are followed by a block patter...
Status: NEW
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: Editor (show other bugs)
Version: 13.0   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2016-06-30 10:02 EDT by Alex Tugarev CLA
Modified: 2017-01-06 15:28 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Tugarev CLA 2016-06-30 10:02:18 EDT
Consider the following patterns for the highlighting configuration:

patterns: [
 {include: "orion.lib#string_doubleQuote"},
 {include: "orion.lib#string_singleQuote"},
 {include: "orion.lib#brace_open"},
 {include: "orion.lib#brace_close"},
 {include: "orion.lib#bracket_open"},
 {include: "orion.lib#bracket_close"},
 {include: "orion.lib#parenthesis_open"},
 {include: "orion.lib#parenthesis_close"},
 {include: "orion.lib#number_decimal"},
 {include: "orion.lib#number_hex"}
]

Braket matching won't work if one add a block pattern (e.g. {include: "orion.lib#doc_block"}) at the end of this array.

Have a look at the function TextStyler#_initPatterns. It is assumed, that the block patterns are at the beginning of the array:

block.blockPatterns = block.linePatterns.slice(0, lastBlock + 1);

But if there is a block pattern after the section patterns, then all of them are treated as block patterns. This breaks at least the bracket matching. 

I have added a notice to https://wiki.eclipse.org/Orion/Documentation/Developer_Guide/Plugging_into_the_editor#orion.edit.highlighter.

If you like, I'd contribute a change to filter for block patterns instead of slicing the array by index.
Comment 1 Grant Gayed CLA 2016-06-30 14:23:03 EDT
Yes, there's an implicit assumption that all patterns that precede the last block pattern are treated as block patterns, even if they're defined with single-line match: values.  This is not documented and is a bit of a hack.  I think that changing this without making accompanying changes in some language grammars that depend on it would break them.

I will plan to revisit this in the near future (will be away for the next two weeks).