@jupyterlab/settingregistry
Advanced tools
Comparing version 3.1.0-alpha.3 to 3.1.0-alpha.4
@@ -643,3 +643,2 @@ // Copyright (c) Jupyter Development Team. | ||
const keys = CommandRegistry.normalizeKeys(shortcut).join(RECORD_SEPARATOR); | ||
const { selector } = shortcut; | ||
if (!keys) { | ||
@@ -652,4 +651,5 @@ console.warn('Skipping this shortcut because there are no actionable keys on this platform', shortcut); | ||
} | ||
const { selector } = shortcut; | ||
if (!(selector in memo[keys])) { | ||
memo[keys][selector] = false; // User shortcuts are `false`. | ||
memo[keys][selector] = false; // Do not warn if a default shortcut conflicts. | ||
return true; | ||
@@ -660,9 +660,13 @@ } | ||
}); | ||
// If a default shortcut collides with another default, warn and filter. | ||
// If a shortcut has already been added by the user preferences, filter it | ||
// out too (this includes shortcuts that are disabled by user preferences). | ||
defaults = defaults.filter(shortcut => { | ||
const { disabled } = shortcut; | ||
// If a default shortcut collides with another default, warn and filter, | ||
// unless one of the shortcuts is a disabling shortcut (so look through | ||
// disabled shortcuts first). If a shortcut has already been added by the | ||
// user preferences, filter it out too (this includes shortcuts that are | ||
// disabled by user preferences). | ||
defaults = [ | ||
...defaults.filter(s => !!s.disabled), | ||
...defaults.filter(s => !s.disabled) | ||
].filter(shortcut => { | ||
const keys = CommandRegistry.normalizeKeys(shortcut).join(RECORD_SEPARATOR); | ||
if (disabled || !keys) { | ||
if (!keys) { | ||
return false; | ||
@@ -673,15 +677,16 @@ } | ||
} | ||
const { selector } = shortcut; | ||
const { disabled, selector } = shortcut; | ||
if (!(selector in memo[keys])) { | ||
memo[keys][selector] = true; // Default shortcuts are `true`. | ||
// Warn of future conflicts if the default shortcut is not disabled. | ||
memo[keys][selector] = !disabled; | ||
return true; | ||
} | ||
// Only warn if a default shortcut collides with another default shortcut. | ||
// We have a conflict now. Warn the user if we need to do so. | ||
if (memo[keys][selector]) { | ||
console.warn('Skipping this shortcut because it collides with another shortcut.', shortcut); | ||
console.warn('Skipping this default shortcut because it collides with another default shortcut.', shortcut); | ||
} | ||
return false; | ||
}); | ||
// Filter out disabled user shortcuts and concat defaults before returning. | ||
return user.filter(shortcut => !shortcut.disabled).concat(defaults); | ||
// Return all the shortcuts that should be registered | ||
return user.concat(defaults).filter(shortcut => !shortcut.disabled); | ||
} | ||
@@ -688,0 +693,0 @@ SettingRegistry.reconcileShortcuts = reconcileShortcuts; |
{ | ||
"name": "@jupyterlab/settingregistry", | ||
"version": "3.1.0-alpha.3", | ||
"version": "3.1.0-alpha.4", | ||
"description": "Settings registry for Jupyterlab", | ||
@@ -39,3 +39,3 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"dependencies": { | ||
"@jupyterlab/statedb": "^3.1.0-alpha.3", | ||
"@jupyterlab/statedb": "^3.1.0-alpha.4", | ||
"@lumino/commands": "^1.12.0", | ||
@@ -49,3 +49,3 @@ "@lumino/coreutils": "^1.5.3", | ||
"devDependencies": { | ||
"@jupyterlab/testutils": "^3.1.0-alpha.3", | ||
"@jupyterlab/testutils": "^3.1.0-alpha.4", | ||
"@types/jest": "^26.0.10", | ||
@@ -61,3 +61,3 @@ "@types/json5": "^0.0.30", | ||
}, | ||
"gitHead": "5853742351a481cf20e487921a9595108dfee4bf" | ||
"gitHead": "4c82a5a363e2a337288c7f0b3d796627be3f193e" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80826
1674