"Highlight matching bracket" option doesn't highlight brackets with more than 2000 characters between them

Bug #74893 reported by Richard Gobeille
2
Affects Status Importance Assigned to Milestone
GtkSourceView
Fix Released
Wishlist
gtksourceview (Ubuntu)
Fix Released
Wishlist
Ubuntu Desktop Bugs

Bug Description

gedit fails to highlight matching brackets which have more than 2000 characters between them. If I have a long-ish block of code in which the opening and closing brackets are greater than 2000 characters apart, I'm unable to leave the input cursor sitting next to one and have the other be highlighted when I scroll to it. If they are less than 2000 characters apart, things work as expected.

Steps to reproduce:

1) Open gedit
2) Enable the "highlight matching bracket" option in preferences
3) Insert a "{" on line 1
4) Insert 2000 characters of your choice, followed by a "}"
5) Leave the cursor next to one of the brackets and then scroll to the other bracket. The bracket will not be highlighted. If you remove a character and repeat, the bracket will be highlighted as expected.

Seems like this is a simple fix.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your bug. That's a design decision from upstream apparently:

gtksourceview/gtksourcebuffer.c:#define MAX_CHARS_BEFORE_FINDING_A_MATCH 2000

The limit is probably used for performance reasons and upstream though 2000 chars is a good limit for a block. Do you have many code block over that number? What would be a good limit for you?

Changed in gedit:
assignee: nobody → desktop-bugs
importance: Undecided → Wishlist
status: Unconfirmed → Confirmed
Revision history for this message
Sebastien Bacher (seb128) wrote :

I've forwarded that request upstream: http://bugzilla.gnome.org/show_bug.cgi?id=384029

Revision history for this message
Richard Gobeille (rich-envision7) wrote :

Yeah, I have a /lot/ of code blocks that go over that number. For instance, the block of code that I first noticed this issue with is only about 70 lines long, but it still manages to hit the 2000 character limit. 70 lines with an average of ~30 characters per line really isn't much, especially when ~50 of those lines are visible in the editor at once.

I took a look at the upstream bug you filed, and its response, and I would be interested to know what kind of performance problems were encountered before the limit was instituted (and why this was seen as the best solution). I just experimented a bit myself and found that gedit's performance remained adequate (to me), even with the limit you mentioned having been increased to 65536. However, I did perceive what seemed like a slight amount of "hitching" when rapidly moving between many lines with brackets which needed matching. It seems like this could potentially be alleviated by waiting for the user to let up on the cursor keys before figuring out which bracket matches what is at the cursor position.

What are your thoughts?

Changed in gtksourceview:
status: Unknown → Unconfirmed
Revision history for this message
Sebastien Bacher (seb128) wrote :

I've forwarded your comment upstream. I've suggested to change the limit to 4000 maybe. Do you think that would be fine or still too low?

Revision history for this message
Richard Gobeille (rich-envision7) wrote :

4000 is still pretty low... do you suppose it would be feasible to add a gconf key to control this behavior?

Changed in gtksourceview:
status: New → Confirmed
Changed in gtksourceview:
status: Confirmed → Triaged
Revision history for this message
Martin Mai (mrkanister-deactivatedaccount-deactivatedaccount) wrote :
Changed in gtksourceview (Ubuntu):
status: Triaged → Fix Released
Changed in gtksourceview:
importance: Unknown → Wishlist
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.