From 35cac93b97be6d1a4090ec9d46a3aa75bafb128c Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 8 Aug 2019 17:33:50 +0200 Subject: [PATCH 1/2] list.clear should clear both focus and selection in one go --- src/vs/workbench/browser/actions/listCommands.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/browser/actions/listCommands.ts b/src/vs/workbench/browser/actions/listCommands.ts index 634dcd6959934..e7c711e378b65 100644 --- a/src/vs/workbench/browser/actions/listCommands.ts +++ b/src/vs/workbench/browser/actions/listCommands.ts @@ -751,7 +751,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ if (list.getSelection().length > 0) { list.setSelection([]); - } else if (list.getFocus().length > 0) { + } + if (list.getFocus().length > 0) { list.setFocus([]); } } @@ -763,7 +764,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ if (list.getSelection().length > 0) { list.setSelection([], fakeKeyboardEvent); - } else if (list.getFocus().length > 0) { + } + if (list.getFocus().length > 0) { list.setFocus([], fakeKeyboardEvent); } } @@ -774,7 +776,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ if (tree.getSelection().length) { tree.clearSelection({ origin: 'keyboard' }); - } else if (tree.getFocus()) { + } + if (tree.getFocus()) { tree.clearFocus({ origin: 'keyboard' }); } } From 2da0f12ee44e4870d26ee2df04d9ba55b2c2ec09 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 8 Aug 2019 17:59:09 +0200 Subject: [PATCH 2/2] simplify --- .../workbench/browser/actions/listCommands.ts | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/vs/workbench/browser/actions/listCommands.ts b/src/vs/workbench/browser/actions/listCommands.ts index e7c711e378b65..a811aed2a8291 100644 --- a/src/vs/workbench/browser/actions/listCommands.ts +++ b/src/vs/workbench/browser/actions/listCommands.ts @@ -749,12 +749,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ if (focused instanceof List || focused instanceof PagedList) { const list = focused; - if (list.getSelection().length > 0) { - list.setSelection([]); - } - if (list.getFocus().length > 0) { - list.setFocus([]); - } + list.setSelection([]); + list.setFocus([]); } // ObjectTree @@ -762,24 +758,16 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ const list = focused; const fakeKeyboardEvent = new KeyboardEvent('keydown'); - if (list.getSelection().length > 0) { - list.setSelection([], fakeKeyboardEvent); - } - if (list.getFocus().length > 0) { - list.setFocus([], fakeKeyboardEvent); - } + list.setSelection([], fakeKeyboardEvent); + list.setFocus([], fakeKeyboardEvent); } // Tree else if (focused) { const tree = focused; - if (tree.getSelection().length) { - tree.clearSelection({ origin: 'keyboard' }); - } - if (tree.getFocus()) { - tree.clearFocus({ origin: 'keyboard' }); - } + tree.clearSelection({ origin: 'keyboard' }); + tree.clearFocus({ origin: 'keyboard' }); } } });