Commits

rablador  committed 2682ffa

Fixed bug that made alphabetical sorting not work as intended in all cases. Added setting to sort commands alphabetically or in the order that they are added to the settings file.

  • Participants
  • Parent commits d8f2076

Comments (0)

Files changed (5)

 *.png
-*.pyc
+*.pyc
+package-metadata.json

File ChangeLog.txt

 Ver 1.0
 =======
 
-First release!
+First release!
+
+Ver 1.05
+=======
+
+Fixed bug that made alphabetical sorting not work as intended in all cases.
+Added setting to sort commands alphabetically or in the order that they are added to the settings file.
     self.command_list = None
     self.run_commands = None
     self.hardcore_mode = False
+    self.sort_alphabetically = True
 
   def run(self):
     # If the command list has not be defined, run the plugin.
         self.command_list = []
         self.run_commands = []
         self.hardcore_mode = settings['hardcore_mode']
+        self.sort_alphabetically = settings['sort_alphabetically']
 
         for command in commands:
           # If there is a user added caption, display that in the list instead of the command.
           command_item = [caption] + [command['command']] + [args]
           self.run_commands.append(command_item)
 
-        # Sort both lists alphabetically. Makes the user experience better and syncs the lists with each other.
-        self.command_list.sort()
-        self.run_commands.sort()
+        # Sort lists alphabetically. Both lists have to be sorted in order to keep the lists
+        # synchronized with each other.
+        if self.sort_alphabetically:
+          self.command_list.sort(key = lambda list: list[0].lower())
+          self.run_commands.sort(key = lambda list: list[0].lower())
+
         # Display caption and keyboard shortcuts to quick panel.
         sublime.active_window().show_quick_panel(self.command_list, self.on_select)
+
       except Exception, e:
         print e
 

File QuickRef.sublime-settings

   {
     // Hardcore mode will not allow you to run any commands from the command palette, thus forcing
     // you to remember them instead.
-    "hardcore_mode": false
+    "hardcore_mode": false,
+
+    // Sort commands alphabetically or in the order that they are added to the settings file.
+    "sort_alphabetically": true
   },
 
   "commands": 
 #### Hardcore mode
 Hardcore mode will not allow you to run any commands from the command palette, thus forcing you to remember them instead.
 
+#### Sort alphabetically
+Sort commands alphabetically or in the order that they are added to the settings file.
+
 ## About
 --------
 QuickRef is created by Rablador. The code is free to use for whomever finds use for it.