Skip to content

Commit

Permalink
Merge pull request #112 from dustinparker/development
Browse files Browse the repository at this point in the history
Added feature request #106
  • Loading branch information
cschindl authored Sep 29, 2017
2 parents 665de24 + 9367a8c commit ac03521
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/config/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
"type": "boolean",
"default": true,
"order": 6
},
"sortServerProfilesByName": {
"title": "List Servers By Name",
"description": "When listing servers in the FTP-Remote-Edit view, list servers by name rather than by host.",
"type": "boolean",
"default": true,
"order": 7
}
},
"order": 3
Expand Down
15 changes: 13 additions & 2 deletions lib/views/tree-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ class TreeView extends ScrollView {
self.reload();
}
});
atom.config.onDidChange('ftp-remote-edit.tree.sortServerProfilesByName', () => {
if (self.isVisible()) {
self.reload();
}
});
atom.config.onDidChange('ftp-remote-edit.tree.hideIgnoredNames', () => {
self.ignoredPatterns = self.loadIgnoredPatterns();
if (self.isVisible()) {
Expand Down Expand Up @@ -244,10 +249,16 @@ class TreeView extends ScrollView {
let configHash = atom.config.get('ftp-remote-edit.config');
if (configHash) {
let config = decrypt(password, configHash);
let sortServerProfilesByName = atom.config.get('ftp-remote-edit.tree.sortServerProfilesByName');
self.servers = JSON.parse(cleanJsonString(config));
self.servers.sort(function (a, b) {
if (a.host < b.host) return -1;
if (a.host > b.host) return 1;
if (sortServerProfilesByName) {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
} else {
if (a.host < b.host) return -1;
if (a.host > b.host) return 1;
}
return 0;
});
}
Expand Down

0 comments on commit ac03521

Please sign in to comment.