diff --git a/platform/lang-impl/src/com/intellij/codeInsight/generation/surroundWith/PopupActionChooser.java b/platform/lang-impl/src/com/intellij/codeInsight/generation/surroundWith/PopupActionChooser.java index 1404ba0fa919..66514b677cf2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/generation/surroundWith/PopupActionChooser.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/generation/surroundWith/PopupActionChooser.java @@ -80,15 +80,17 @@ public class PopupActionChooser { applicable.addSeparator("Live templates"); } - for (CustomLiveTemplate customTemplate : customTemplates) { - applicable.add(new WrapWithCustomTemplateAction(customTemplate, editor, file, usedMnemonicsSet)); - hasEnabledSurrounders = true; - } for (TemplateImpl template : templates) { applicable.add(new InvokeTemplateAction(template, editor, project, usedMnemonicsSet)); hasEnabledSurrounders = true; } - if (!templates.isEmpty()) { + + for (CustomLiveTemplate customTemplate : customTemplates) { + applicable.add(new WrapWithCustomTemplateAction(customTemplate, editor, file, usedMnemonicsSet)); + hasEnabledSurrounders = true; + } + + if (!templates.isEmpty() || !customTemplates.isEmpty()) { applicable.addSeparator(); applicable.add(new ConfigureTemplatesAction()); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java index 329faae575a2..c304ad30b860 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/SurroundWithTemplateHandler.java @@ -54,13 +54,15 @@ public class SurroundWithTemplateHandler implements CodeInsightActionHandler { Set usedMnemonicsSet = new HashSet(); DefaultActionGroup group = new DefaultActionGroup(); - for (CustomLiveTemplate customTemplate : customTemplates) { - group.add(new WrapWithCustomTemplateAction(customTemplate, editor, file, usedMnemonicsSet)); - } + for (TemplateImpl template : templates) { group.add(new InvokeTemplateAction(template, editor, project, usedMnemonicsSet)); } + for (CustomLiveTemplate customTemplate : customTemplates) { + group.add(new WrapWithCustomTemplateAction(customTemplate, editor, file, usedMnemonicsSet)); + } + final ListPopup popup = JBPopupFactory.getInstance() .createActionGroupPopup(CodeInsightBundle.message("templates.select.template.chooser.title"), group, DataManager.getInstance().getDataContext(editor.getContentComponent()),