Skip to content

Commit

Permalink
Allow navigation names which use same name as hardcoded defaults #79
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Jul 13, 2019
1 parent e48028f commit bbb7b9f
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/todoist-shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2665,15 +2665,8 @@
for (keys in groups) {
if (noAliasing(keys)) {
var groupItems = groups[keys];
var isUnique = groupItems.length === 1;
var qualifies = false;
if (mode === 'must-be-unique') {
if (!isUnique) {
error('keys', keys, 'must be unique.');
} else {
qualifies = true;
}
} else if (mode === 'allow-ambiguous') {
if (mode === 'no-shortening') {
qualifies = true;
} else if (mode === 'try-shortening') {
// Prefer shortened key sequences if they are unambiguous.
Expand Down Expand Up @@ -2701,8 +2694,6 @@
} else {
error('Invariant violation: unexpected mode in addViaKeyFunc');
}
// Non-aliasing sequence which is unambiguous if ambiguousAddFirst is
// false.
if (qualifies) {
qualifying.push([keys, groupItems[0]]);
}
Expand All @@ -2720,10 +2711,10 @@
}
};
// Handle items with 'mustBeKeys' set.
addViaKeyFunc('must-be-unique', function(it) { return it.mustBeKeys; });
addViaKeyFunc('no-shortening', function(it) { return it.mustBeKeys; });
// When initials are at least MAX_NAVIGATE_PREFIX in length, prefer
// assigning those.
addViaKeyFunc('allow-ambiguous', function(it) {
addViaKeyFunc('no-shortening', function(it) {
var initials = it.initials;
if (initials.length >= MAX_NAVIGATE_PREFIX) {
return initials.slice(0, MAX_NAVIGATE_PREFIX);
Expand Down

0 comments on commit bbb7b9f

Please sign in to comment.