Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/project/WorkingSetSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ define(function (require, exports, module) {
*/
function setAutomatic(enable) {
_automaticSort = enable;
PreferencesManager.setViewState("automaticSort", _automaticSort);
CommandManager.get(Commands.SORT_WORKINGSET_AUTO).setChecked(_automaticSort);
PreferencesManager.setViewState("automaticSort", enable);
CommandManager.get(Commands.SORT_WORKINGSET_AUTO).setChecked(enable);
_currentSort.setChecked(enable);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't currentSort always be checked? I've not seen a situation where this isn't the case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i should have said: isn't it always checked...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not with this PR. Current Sort is only checked when Automatic Sort is checked.

If the current sort is checked, and you manually sort the files, it gets unchecked,


if (enable) {
_currentSort.sort();
Expand Down Expand Up @@ -146,19 +147,15 @@ define(function (require, exports, module) {
var command;
if (_currentSort !== newSort) {
if (_currentSort !== null) {
command = CommandManager.get(_currentSort.getCommandID());
if (command) {
command.setChecked(false);
}
_currentSort.setChecked(false);
}
command = CommandManager.get(newSort.getCommandID());
if (command) {
command.setChecked(true);
if (_automaticSort) {
newSort.setChecked(true);
}

CommandManager.get(Commands.SORT_WORKINGSET_AUTO).setEnabled(!!newSort.getEvents());
PreferencesManager.setViewState("currentSort", newSort.getCommandID());
_currentSort = newSort;
PreferencesManager.setViewState("currentSort", _currentSort.getCommandID());
}
}

Expand Down Expand Up @@ -194,6 +191,17 @@ define(function (require, exports, module) {
return this._events;
};

/**
* Checks/Unchecks the command which will show a check in the menu
* @param {boolean} value
*/
Sort.prototype.setChecked = function (value) {
var command = CommandManager.get(this._commandID);
if (command) {
command.setChecked(value);
}
};

/**
* Performs the sort and makes it the current sort method.
*/
Expand Down