fix ConfigurablesModifiedTest with respect to live templates configurable
authorpeter <peter@jetbrains.com>
Thu, 12 Feb 2015 18:41:05 +0000 (19:41 +0100)
committerpeter <peter@jetbrains.com>
Thu, 12 Feb 2015 18:48:22 +0000 (19:48 +0100)
platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java

index 24efa6e9dd93da7c74b6382ab425d02fd68b9549..2af7399f8d746ec9457c990ab3ef5f341a92071f 100644 (file)
@@ -118,14 +118,7 @@ public class TemplateListPanel extends JPanel implements Disposable {
     myTemplateContext.clear();
 
     TemplateSettings templateSettings = TemplateSettings.getInstance();
-    List<TemplateGroup> groups = new ArrayList<TemplateGroup>(templateSettings.getTemplateGroups());
-
-    Collections.sort(groups, new Comparator<TemplateGroup>() {
-      @Override
-      public int compare(@NotNull TemplateGroup o1, @NotNull TemplateGroup o2) {
-        return o1.getName().compareToIgnoreCase(o2.getName());
-      }
-    });
+    List<TemplateGroup> groups = getSortedGroups(templateSettings);
 
     initTemplates(groups, templateSettings.getLastSelectedTemplateGroup(), templateSettings.getLastSelectedTemplateKey());
     myExpandByDefaultPanel.setSelectedChar(templateSettings.getDefaultShortcutChar());
@@ -139,6 +132,19 @@ public class TemplateListPanel extends JPanel implements Disposable {
     myUpdateNeeded = true;
   }
 
+  @NotNull
+  private static List<TemplateGroup> getSortedGroups(TemplateSettings templateSettings) {
+    List<TemplateGroup> groups = new ArrayList<TemplateGroup>(templateSettings.getTemplateGroups());
+
+    Collections.sort(groups, new Comparator<TemplateGroup>() {
+      @Override
+      public int compare(@NotNull TemplateGroup o1, @NotNull TemplateGroup o2) {
+        return o1.getName().compareToIgnoreCase(o2.getName());
+      }
+    });
+    return groups;
+  }
+
   public void apply() throws ConfigurationException {
     List<TemplateGroup> templateGroups = getTemplateGroups();
     for (TemplateGroup templateGroup : templateGroups) {
@@ -186,7 +192,7 @@ public class TemplateListPanel extends JPanel implements Disposable {
       return true;
     }
 
-    List<TemplateGroup> originalGroups = templateSettings.getTemplateGroups();
+    List<TemplateGroup> originalGroups = getSortedGroups(templateSettings);
     List<TemplateGroup> newGroups = getTemplateGroups();
 
     List<TemplateImpl> originalGroup = collectTemplates(originalGroups);