Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

New prefence for mac to sort the directories first in the project tree #7138

Merged
merged 3 commits into from
Mar 10, 2014

Conversation

TomMalbran
Copy link
Contributor

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. :)

@redmunds redmunds self-assigned this Mar 9, 2014
* @return {string}
*/
function _getSortPrefix(isFolder) {
if (brackets.platform === "mac" && !PreferencesManager.get("sortDirsFirst")) {
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@redmunds
Copy link
Contributor

redmunds commented Mar 9, 2014

Preferences for all the things!

@TomMalbran
Copy link
Contributor Author

@redmunds Fixes pushed.

*/
var _isMac = brackets.platform === "mac",
_sortPrefixDir = _isMac ? "" : "0",
_sortPrefixFile = _isMac ? "" : "1";
Copy link
Contributor

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)

Copy link
Contributor Author

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.

@TomMalbran
Copy link
Contributor Author

@redmunds I just pushed the performance fix.

@redmunds
Copy link
Contributor

Looks good. Merging.

redmunds added a commit that referenced this pull request Mar 10, 2014
New prefence for mac to sort the directories first in the project tree
@redmunds redmunds merged commit 34db31a into master Mar 10, 2014
@redmunds redmunds deleted the tom/sort-dirs-first branch March 10, 2014 23:35
@peterflynn peterflynn mentioned this pull request Aug 7, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants