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 562675 - Copy/paste highlighted matching bracket
Copy/paste highlighted matching bracket
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
1.6.x
Other Linux
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-29 13:11 UTC by jessevdk@gmail.com
Modified: 2010-04-24 18:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Match bracket bug screenshot (24.21 KB, image/png)
2008-11-29 13:12 UTC, jessevdk@gmail.com
  Details
Apply matching bracket tag only when needed (3.08 KB, patch)
2010-04-23 16:48 UTC, jessevdk@gmail.com
committed Details | Review

Description jessevdk@gmail.com 2008-11-29 13:11:30 UTC
When you copy selected text with matching bracket highlighting on, and the matching bracket is highlighted in the selection, this highlighting is copied when the selected text is copied. When pasting the text, the highlighted matched bracket stays highlighted. I guess this happens because the tag applied to the bracket is copied and pasted also. This only happens when selecting from end to start of two brackets because when pasting, the cursor is placed at the end bracket. When selecting from start to end, the start bracket is correctly highlighted still when pasting because the cursor is actually at the end bracket. The highlighting is properly removed once the cursor is placed at the starting bracket after pasting, and then moved to a different character.

This can be easily reproduced in for example gedit:
1. Activate highlight matching bracket option
2. Open new document
3. Set highlighting language to C
4. Type: (hello world)
5. Select text from end to start
6. Copy text (Ctrl+C)
7. Paste text somewhere in the buffer, last bracket stays highlighted
Comment 1 jessevdk@gmail.com 2008-11-29 13:12:08 UTC
Created attachment 123644 [details]
Match bracket bug screenshot

Attached screenshot of the problem
Comment 2 jessevdk@gmail.com 2010-04-23 16:48:54 UTC
Created attachment 159450 [details] [review]
Apply matching bracket tag only when needed

This patch fixes the problem. It does so by overriding the apply_tag signal handler and only chaining up when the tag is not the matching-bracket tag, or we specifically wanted to apply the tag from the buffer.

I could not find a better way to specify in gtktextbuffer that you don't want some tags to be copied, so this means that if you paste in something that doesn't share the tag table, it doesn't work. However, I think this is not supported anyway, so the patch should be fine.