diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java index 770375a7477..6dc4c3683c3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java @@ -296,11 +296,15 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD TemplateCompletionProposalComputer templateComputer = new TemplateCompletionProposalComputer(); CContentAssistInvocationContext context = new CContentAssistInvocationContext( editor.getViewer(), textSelection.getOffset(), editor, true, false ); - List proposals= templateComputer.computeCompletionProposals(context, null); - if (proposals == null || proposals.isEmpty()) - return null; - - return getActionsFromProposals(proposals, context.getInvocationOffset(), editor.getViewer()); + try { + List proposals= templateComputer.computeCompletionProposals(context, null); + if (proposals == null || proposals.isEmpty()) + return null; + + return getActionsFromProposals(proposals, context.getInvocationOffset(), editor.getViewer()); + } finally { + context.dispose(); + } } private static ITextSelection getTextSelection(CEditor editor) {