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 756537 - Improve/fix matching bracket
Improve/fix matching bracket
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Sébastien Wilmet
GTK Sourceview maintainers
: 629786 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-10-13 23:00 UTC by Christian Hergert
Modified: 2015-10-25 14:34 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Christian Hergert 2015-10-13 23:00:44 UTC
if ((ch == '{') && find_previous_char (iter) == ')')
     ^.............................................^

We would expect the last one to match.
Comment 1 Christian Hergert 2015-10-13 23:01:19 UTC
And of course bugzilla ruined the formatting!

The first ( was matching the ')'
Comment 2 Paolo Borelli 2015-10-14 06:05:47 UTC
I guess we need to make the bracket matching be aware of class contexts so that we can skip "strings" etc. This would also require to add class contexts for "character" and "escape sequence".
Comment 3 Sébastien Wilmet 2015-10-14 08:35:00 UTC
*** Bug 629786 has been marked as a duplicate of this bug. ***
Comment 4 Sébastien Wilmet 2015-10-14 08:37:58 UTC
Ignoring the string and comment context classes would already be a big improvement.

And, inside a string or comment, match brackets only in that string/comment?
Comment 5 Sébastien Wilmet 2015-10-16 15:42:34 UTC
Actually the string and comment context classes are taken into account, but there are some bugs.

And in C a single character like '(' is not seen as a string, so there are problems in that case.

An idea is to add the string context class for single characters too. It can be seen as a string of one char. I don't know if some code relies on the fact that the string context class, in C, delimits a real string with double quotes.
Comment 6 Sébastien Wilmet 2015-10-25 14:34:47 UTC
Fixed:
https://git.gnome.org/browse/gtksourceview/commit/?id=63faf76e1a4d8ecf6e4b3568e015b34c7d62a476

After 4 other bug fixes and lots of code simplification for the bracket matching.