diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index 833576847ae6..dd2c4a4c40d4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -35,6 +35,7 @@ import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.Alarm; import com.intellij.util.ui.ColumnInfo; import com.intellij.util.ui.UIUtil; +import com.intellij.util.ui.tree.TreeUtil; import com.intellij.util.ui.update.UiNotifyConnector; import org.jetbrains.annotations.Nullable; @@ -494,6 +495,17 @@ class TemplateListPanel extends JPanel { myTree.setSelectionInterval(selected, selected); updateTemplateTextArea(); + + List expandedPaths = TreeUtil.collectExpandedPaths(myTree); + TreePath[] selectedPaths = myTree.getSelectionPaths(); + ((DefaultTreeModel)myTree.getModel()).nodeStructureChanged(myTreeRoot); + TreeUtil.restoreExpandedPaths(myTree, expandedPaths); + if (selectedPaths != null) { + myTree.setSelectionPaths(selectedPaths); + } + + myTree.validate(); + myTree.repaint(); } private Map getOptions(final TemplateImpl template) {