GNOME Bugzilla – Bug 562675
Copy/paste highlighted matching bracket
Last modified: 2010-04-24 18:00:36 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
Created attachment 123644 [details] Match bracket bug screenshot Attached screenshot of the problem
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.