Community
Participate
Working Groups
Build Identifier: I20110407-2200 OS: RedHat Linux Enterprise 6.0 Eclipse SDK Version: 4.1.0 Build id: I20110407-2200 Plug-in Manifest Editor add garbage after '&' + mnemonics when it save plugin.xml. For example. "Sample Menu(&M)" is changed into "Sample Menu(&M)Menu". "Sample Action(&S)" is changed into "Sample Action(&S)tion". Expressions (&M),(&S) are important and popular formats for DBCS to use mnemonics Reproducible: Always Steps to Reproduce: 1.Import Project 'bugXXXXX.zip" attached to this report. 2.This project is a plug-in project generated from Template 'Hello, World'. 3.Open 'plugin.xml' with Plug-in Manifest Editor. 4.Click Tab 'Extensions', 5.Verify Menu 'Sample Menu(&M)Menu", Action 'Sample Action(&S)tion'. 6.Those have been already corrupted. 7.Edit them into 'Sample Menu(&M)', 'Sample Action(&S)'. 8.Save the file, but the labels are corrupted again.
Created attachment 193003 [details] bug342512.zip I attached a plug-in project to reproduce this bug.
Reproduced, very odd behaviour.
The problem is that the ReplaceEdit operation is getting the incorrect old value length. Somewhere (getWritableAttributeNodeValue?) we replace the & with amp;, but when we calculate the length we haven't replaced it yet giving a shorter length. This manifests in the same way as bug 331485 with each edit replacing the wrong text. cc'ing Dani so he is aware. Should be able to fix it by running the replace method on the event's old value.
Proposed fix, replace line 233 of XMLInputContext with: oldLength = getWritableAttributeNodeValue(((String) event.getOldValue())).length(); Inside addAttributeOperation() we just get event.getOldValue() to get the length. However the event is generated from the model not the xml and the & is translated afterwards. By translating the old value before checking its length we get the proper result. I didn't create a patch as it conflicts with the fix on bug 331485 that is waiting to be committed. Dani, please review this fix for RC1 inclusion.
+1 for the fix for RC1. However, this exhibits a general problem with the transformation code for special characters: the extension point doc tells the user to use "&" instead of '&' but it doesn't say that '&' inside the PDE editor is good enough (or actually: the only valid form). Now, if the user types "&" as indicated on the help page he will end up with "&". This is with or without the patch and should be handled by a new bug.
Fixed in HEAD. Opened Bug 345165 to improve the character replacement.
Verified in I20110514-0800