diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java index 1832fd677c6..500dec06eb2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java @@ -1047,7 +1047,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha */ public boolean show(ShowInContext context) { ISelection selection= context.getSelection(); - if (selection != null) { + if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { selectReveal(selection); return true; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index 7ed7305c216..b1270ee3c70 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -1246,17 +1246,18 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC ICElement ce= null; try { ce= SelectionConverter.getElementAtOffset(this); + if (ce instanceof ITranslationUnit) { + ce = null; + } } catch (CModelException ex) { ce= null; } - if (ce != null) { - final ISelection selection= new StructuredSelection(ce); - return new IShowInSource() { - public ShowInContext getShowInContext() { - return new ShowInContext(getEditorInput(), selection); - } - }; - } + final ISelection selection= ce != null ? new StructuredSelection(ce) : null; + return new IShowInSource() { + public ShowInContext getShowInContext() { + return new ShowInContext(getEditorInput(), selection); + } + }; } if (ProjectionAnnotationModel.class.equals(required)) { if (fProjectionSupport != null) {