-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New prefence for mac to sort the directories first in the project tree #7138
Conversation
* @return {string} | ||
*/ | ||
function _getSortPrefix(isFolder) { | ||
if (brackets.platform === "mac" && !PreferencesManager.get("sortDirsFirst")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this preference should not be Mac-only. User should be able to specify something like "directoriesFirst" or "alphabetical". If this preference is not specified, then the current sorting is used.
Do we need a separate pref for "ignoreCase"? Windows ignores case, but some systems may use strict ASCII order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be easy to just change the default value of this pref to false or true depending on the OS, so when defined by the user, it won't matter which OS they are using.
Currently we always ignore cases for any OS. Do you know of any OS or anyone who would like it to add an extra pref? Should that pref affect when we compare filenames in any operation, or just for the project tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be easy to just change the default value of this pref to false or true depending on the OS
Sounds good.
Do you know of any OS or anyone who would like it to add an extra pref?
I haven't heard anyone request it, so that can be added later.
Preferences for all the things! |
@redmunds Fixes pushed. |
*/ | ||
var _isMac = brackets.platform === "mac", | ||
_sortPrefixDir = _isMac ? "" : "0", | ||
_sortPrefixFile = _isMac ? "" : "1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code works as desired, but I am concerned about performance. The PreferencesManager.get("sortDirectoriesFirst")
function gets called on average O(n * log(n))
times for a list with n
items, but it returns the same value every time. I think the original code is better -- only need to use preference instead of platform.
var _dirFirst = PreferencesManager.get("sortDirectoriesFirst"),
_sortPrefixDir = _dirFirst ? "0" : "",
_sortPrefixFile = _dirFirst ? "1" : "";
UPDATE: fixed original logic (was reversed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I am not sure how many operation PreferencesManager.get("sortDirectoriesFirst")
does, but it might be better if it was saved as a variable or as you mention the prefixes too. I'll fix this.
@redmunds I just pushed the performance fix. |
Looks good. Merging. |
New prefence for mac to sort the directories first in the project tree
The new preference made it really easy to add a new pref requested several times to sort the directories first in the projects tree in a mac without needing to add a new menu item. :)