Skip to content

Commit

Permalink
Make gist sort order configurable (improves on #107)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgreenlee committed Jul 14, 2017
1 parent fc00d94 commit 05b7e3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions GitHub.sublime-settings
Expand Up @@ -34,6 +34,10 @@
"gist_list_format": "%(filename)s: %(description)s",
// If true, display the list of gists in a monospace font
"gist_list_monospace": false,
// [sort key, order (true = reversed)] for the list of gists; valid values are any of the top-level
// elements in the gist API response. E.g.: created_at, updated_at, description
// Default is the default sort key & order from GitHub, which is created_at desc
"gist_list_sort_by": ["created_at", true],
// Highlight the line the cursor is on in GitHub, even if the line is not selected
"always_highlight_current_line": false,
// output debug info to the console
Expand Down
6 changes: 4 additions & 2 deletions sublime_github.py
Expand Up @@ -156,8 +156,10 @@ def run(self, edit):

def get_gists(self):
try:
gists = self.gistapi.list_gists(starred=self.starred)
self.gists = sorted(gists, key=lambda x: (x.get("description") or "").lower())
self.gists = self.gistapi.list_gists(starred=self.starred)
sort_by, sort_reversed = self.settings.get("gist_list_sort_by", [None, False])
if sort_by:
self.gists = sorted(self.gists, key=lambda x: (x.get(sort_by) or "").lower(), reverse=sort_reversed)
gist_list_format = self.settings.get("gist_list_format")
packed_gists = []
for idx, gist in enumerate(self.gists):
Expand Down

0 comments on commit 05b7e3e

Please sign in to comment.