mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 11:10:48 +00:00
Treat removing keybindings with when = true
as if they wouldn't have a when clause (#162945)
Fixes #160604: Treat removing keybindings with `when = true` as if they wouldn't have a when clause
This commit is contained in:
parent
6d59844e1c
commit
e97990e4ee
2 changed files with 16 additions and 2 deletions
|
@ -70,7 +70,10 @@ export class KeybindingResolver {
|
|||
if (keypressChordPart && defaultKb.keypressParts[1] !== keypressChordPart) {
|
||||
return false;
|
||||
}
|
||||
if (when) {
|
||||
|
||||
// `true` means always, as does `undefined`
|
||||
// so we will treat `true` === `undefined`
|
||||
if (when && when.type !== ContextKeyExprType.True) {
|
||||
if (!defaultKb.when) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ suite('KeybindingResolver', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
test('issue #157751: Keyboard Shortcuts: Change When Expression might actually remove keybinding in Insiders', () => {
|
||||
test('issue #157751: Auto-quoting of context keys prevents removal of keybindings via UI', () => {
|
||||
const defaults = [
|
||||
kbItem(KeyCode.KeyA, 'command1', null, ContextKeyExpr.deserialize(`editorTextFocus && activeEditor != workbench.editor.notebook && editorLangId in julia.supportedLanguageIds`), true),
|
||||
];
|
||||
|
@ -246,6 +246,17 @@ suite('KeybindingResolver', () => {
|
|||
assert.deepStrictEqual(actual, []);
|
||||
});
|
||||
|
||||
test('issue #160604: Remove keybindings with when clause does not work', () => {
|
||||
const defaults = [
|
||||
kbItem(KeyCode.KeyA, 'command1', null, undefined, true),
|
||||
];
|
||||
const overrides = [
|
||||
kbItem(KeyCode.KeyA, '-command1', null, ContextKeyExpr.true(), false),
|
||||
];
|
||||
const actual = KeybindingResolver.handleRemovals([...defaults, ...overrides]);
|
||||
assert.deepStrictEqual(actual, []);
|
||||
});
|
||||
|
||||
test('contextIsEntirelyIncluded', () => {
|
||||
const toContextKeyExpression = (expr: ContextKeyExpression | string | null) => {
|
||||
if (typeof expr === 'string' || !expr) {
|
||||
|
|
Loading…
Reference in a new issue