Community
Participate
Working Groups
Build Identifier: Eclipse 3.6.2 The default XML editor in Web Tools: org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart does not implement org.eclipse.ui.INavigationLocationProvider. This means that no detailed location information is recorded when org.eclipse.ui.INavigationHistory.markLocation(IEditorPart part) is called, or can be retrieved when the navigation history is navigated (The NavigationHistoryEntry.restoreLocation() method needs the provider interface as well). The effect of not implementing this interface is that text position is not preserved when recording history in XML editors. This is annoying and breaks the fluid Alt+Left navigation at seemingly odd moments, especially within files. Users expect this to work similarly to e.g. Java editors. The solution would be to implement the interface on the multipageditorpart and delegate to the text editor for the implementation. The org.eclipse.wst.xsd.ui.internal.editor.InternalXSDMultiPageEditor would serve as an example, as this does contain this solution already. Reproducible: Always Steps to Reproduce: 1. Be sure that the "Java element" in "XML Editors" is enabled in the "General > Editors> Text Editors > Hyperlinks" workspace preferences. 2. Type some xml in foo.xml file that contains a Java reference, e.g. <element foo="java.lang.String" /> 3. Hover and hold Ctrl to activate the hyperlink and navigate to the Java definition. 4. Select the foo.xml editor and change the selection. 5. Select the String editor and press Alt+Left to trigger navigating the history. 6. Observe that history selection is not correctly restored and the caret stays on the modified position, instead of moving to the historic location when navigating away to String. 7. Observe that while performing similar operations on two Java files, the caret is moved to the correct position. Especially in larger files, this is problematic. I am currently adding my own hyperlink detector that navigates to nodes in the same XML document, and then this becomes even more apparent (Alt+Left does not do anything anymore).
Created attachment 197545 [details] patch
> Object first = ((StructuredSelection) selection).getFirstElement(); (Almost) Never do this; use IStructuredSelection instead.
Created attachment 197609 [details] patch Nice catch, Nitin.
Changes checked in.