After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 140097 - Implement some method to prioritize patterns
Implement some method to prioritize patterns
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
git master
Other All
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks: 130470 139267 363114
 
 
Reported: 2004-04-15 00:15 UTC by Gustavo Giráldez
Modified: 2014-02-15 12:53 UTC
See Also:
GNOME target: ---
GNOME version: 2.7/2.8



Description Gustavo Giráldez 2004-04-15 00:15:08 UTC
Sometimes two patterns can match the *exact same string*.  Currently
GtkSourceView prefers the pattern which can match the longer string, but if two
patterns match the same number of characters the choice is random in practice.

The current highlighting engine should provide some way to prioritize one
pattern over the other.  The obvious mechanism would be to give them priority
according to the order in which they appear in the .lang file.
Comment 1 Travis Snoozy 2004-05-14 18:24:58 UTC
Is someone already in the midst of working on this? If so, I'd like to get in
contact and help; if not, I'd be happy to at least get started taking crack at
it on my own.
Comment 2 Paolo Borelli 2006-07-26 09:54:37 UTC
not sure why this one was NEEDINFO... reopening: this is a known issue of the current engine and we should at least have it visible in bugzilla so that we can adress the problem in the new engine.


Muntyan: I am CC'ing you since you asked about priorities in the current engine.
Comment 3 Yevgen Muntyan 2006-07-26 15:58:55 UTC
Engine looks for a match which has least start offset; then, if two matches start at the same offset, it chooses the one which comes first in lang file (it doesn't really choose, it just tries contexts in order).
Comment 4 Yevgen Muntyan 2007-05-26 20:59:22 UTC
New engine doesn't have this issue (if there was one). It does what's said in comment #3; if it's wrong or not good then it's a design issue with new engine, and new bug should be opened.
Comment 5 Travis Snoozy 2007-05-27 17:54:08 UTC
But the *styles* have a fixed precedence, regardless of order in the .lang file. This is the key problem -- for example, a "string" type always overrides "keyword" types. Currently, it is impossible to highlight keywords inside a string, even if we wanted to. There needs to be a way to say "this group of keywords is more important than string highlighting" so we can get, e.g., "$foo" to highlight in a PHP string, or "\n" to highlight in a C/C++/etc. string.

This problem is by no means limited to strings, its just that strings are one of the easiest places to see this deficiency at work.
Comment 6 Yevgen Muntyan 2007-05-27 18:11:22 UTC
This is done by including one context into another, you can highlight keywords if you like. Now, styles are composed, so e.g. if you have blue string and bold keywords, so keyword in a string will be bold blue. Not sure if you mean it's a problem, but it's certainly as it should be (and you can make keywords bold-and-black in fact). By the way, escape sequences are highlighted in C strings right now.

So, there are certainly bugs, but they are not as simple as this one (and the bug from the *title* is certainly not an issue anymore). Please open new bugs for specific issues, this old one must die.

Note that I am talking about gtksourceview-2 which recently went onto svn trunk, i.e. the new unreleased-yet highlighting engine.
Comment 7 Yevgen Muntyan 2007-05-27 18:21:17 UTC
Sorry for spam. Marking this as FIXED since there are bugs depending on it, and they get marked as OBSOLETE if this one is OBSOLETE.