Bug 94808 - [Change Sets] "&" not showing up in dropdown menu
Summary: [Change Sets] "&" not showing up in dropdown menu
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Team (show other bugs)
Version: 3.1   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 minor (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Platform Team Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2005-05-11 14:19 EDT by Nayan Hajratwala CLA
Modified: 2007-06-05 15:23 EDT (History)
2 users (show)

See Also:
Michael.Valenta: review+


Attachments
Fix by escaping "&", "@", and tab properly (2.20 KB, patch)
2007-05-06 10:04 EDT, Matt McCutchen CLA
no flags Details | Diff
Fix by escaping "&", "@", and tab properly; SIOOBE fixed (2.21 KB, patch)
2007-05-07 20:46 EDT, Matt McCutchen CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nayan Hajratwala CLA 2005-05-11 14:19:37 EDT
Running on OS 10.4 .. not sure if it's a problem on other platforms.

Steps to reproduce:
  1) Create a new Change Set with an ampersand in the name .. i.e. Gags & Games
  2) Right click on another file, select "Add To", the change set shows up as "Gags  Games"
Comment 1 Michael Valenta CLA 2005-05-12 09:56:09 EDT
Seems to be Mac specific. Not for 3.1.
Comment 2 Benjamin Muskalla CLA 2007-05-05 13:19:20 EDT
No, same on GTK.
Comment 3 Matt McCutchen CLA 2007-05-06 10:04:43 EDT
Created attachment 66027 [details]
Fix by escaping "&", "@", and tab properly

This happens because the change set title is used directly as the action text for the menu item, and "&" in action text is interpreted specially as a mnemonic.  The "&" needs to be escaped so it appears literally.  Same with "@" and tab characters for accelerators.

The attached patch fixes the bug by escaping the characters properly for use in action text.
Comment 4 Michael Valenta CLA 2007-05-07 14:22:07 EDT
I got a StringIndexOutOfBoundsException when I tried the patch with a change set name "New & Set". It happens because the "indexOf('&') at the end of the loop doesn't take into consideration the last index of &. Also, the code to handle accelerators doesn't make any sense to me (i.e. \t and @).
Comment 5 Matt McCutchen CLA 2007-05-07 20:46:19 EDT
Created attachment 66230 [details]
Fix by escaping "&", "@", and tab properly; SIOOBE fixed

(In reply to comment #4)
> I got a StringIndexOutOfBoundsException when I tried the patch with a change
> set name "New & Set". It happens because the "indexOf('&') at the end of the
> loop doesn't take into consideration the last index of &.

Oops.  The new attachment fixes that.

> Also, the code to
> handle accelerators doesn't make any sense to me (i.e. \t and @).

I was following the remarks about accelerators in the javadoc for org.eclipse.jface.action.Action#setText .  However, in my testing with HEAD, Eclipse doesn't seem to work as documented: everything after the *first* tab appears right-aligned in the menu as if it's the accelerator.  I don't have time to investigate this now.
Comment 6 Michael Valenta CLA 2007-05-08 13:02:49 EDT
Since the bug only mentioned @ and I'm not convinced that the tab and @ handling is correct, I have removed the tab and @ code and restricted the patch to address &. We can reevaluate later if tab or @ handling is required. Patch reviewed and released.
Comment 7 Matt McCutchen CLA 2007-05-18 19:58:52 EDT
org.eclipse.team.internal.ui.synchronize.actions.ChangeSetActionGroup.AddToChangeSetAction appears to be a copy-and-paste duplicate of ChangeSetActionProvider.AddToChangeSetAction .  I don't know if it's used for anything, but if so, it might need the same fix.
Comment 8 Matt McCutchen CLA 2007-05-18 19:59:50 EDT
I entered bug 187393 for the analogous problem with "@" and tab.
Comment 9 Matt McCutchen CLA 2007-05-18 20:00:29 EDT
I meant bug 187939; sorry for the thinko.
Comment 10 Michael Valenta CLA 2007-05-22 13:41:42 EDT
Verified in I20070522-0010