From 5543d4859986ef90427369d0e9b42bd96e2cc01b Mon Sep 17 00:00:00 2001 From: "Brian J. Cohen" Date: Mon, 27 Mar 2017 11:11:36 -0400 Subject: [PATCH] New setting autoSortByName Signed-off-by: Brian J. Cohen --- lib/main.coffee | 5 +++++ lib/symbols-tree-view.coffee | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/main.coffee b/lib/main.coffee index 4624076..4ca8615 100644 --- a/lib/main.coffee +++ b/lib/main.coffee @@ -19,6 +19,11 @@ module.exports = type: 'string' description: 'Here you can specify a list of types that will be hidden by default (ex: "variable class")' default: '' + autoSortByName: + title: 'Automatically sort by name' + type: 'boolean' + default: false + description: 'If this option is enabled then symbols will be sorted by name by default' sortByNameScopes: type: 'string' description: 'Here you can specify a list of scopes that will be sorted by name (ex: "text.html.php")' diff --git a/lib/symbols-tree-view.coffee b/lib/symbols-tree-view.coffee index 467f859..96504fe 100644 --- a/lib/symbols-tree-view.coffee +++ b/lib/symbols-tree-view.coffee @@ -17,6 +17,7 @@ module.exports = @cachedStatus = {} @contextMenu = new SymbolsContextMenu @autoHideTypes = atom.config.get('symbols-tree-view.zAutoHideTypes') + @autoSortByName = atom.config.get('symbols-tree-view.autoSortByName') @treeView.onSelect ({node, item}) => if item.position.row >= 0 and editor = atom.workspace.getActiveTextEditor() @@ -134,6 +135,10 @@ module.exports = if(@autoHideTypes.indexOf(type) != -1) @treeView.toggleTypeVisible(type) @contextMenu.toggle(type) + if (@autoSortByName) + @treeView.sortByName(true) + @nowSortStatus[0] = true + @updateContextMenu(types) # Returns an object that can be retrieved when package is activated