From bcadb4c1f23f4734238a5768ca47444b3cf988be Mon Sep 17 00:00:00 2001 From: FernandoAscencio Date: Tue, 21 Mar 2023 11:36:29 -0400 Subject: [PATCH] searchInWorkspace: multiselect & `delete` keybind Closes #11874 Implements multiselect in search-in-workspace. Implements `delete` keybinding in search-in-workspace to dismiss results Signed-Off-By: FernandoAscencio --- .../search-in-workspace-frontend-contribution.ts | 11 +++++++++-- .../browser/search-in-workspace-frontend-module.ts | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-frontend-contribution.ts b/packages/search-in-workspace/src/browser/search-in-workspace-frontend-contribution.ts index a432a46505702..ab398a1e8f9d1 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-frontend-contribution.ts +++ b/packages/search-in-workspace/src/browser/search-in-workspace-frontend-contribution.ts @@ -20,7 +20,7 @@ import { } from '@theia/core/lib/browser'; import { SearchInWorkspaceWidget } from './search-in-workspace-widget'; import { injectable, inject, postConstruct } from '@theia/core/shared/inversify'; -import { CommandRegistry, MenuModelRegistry, SelectionService, Command } from '@theia/core'; +import { CommandRegistry, MenuModelRegistry, SelectionService, Command, isOSX } from '@theia/core'; import { codicon, Widget } from '@theia/core/lib/browser/widgets'; import { FileNavigatorCommands, NavigatorContextMenu } from '@theia/navigator/lib/browser/navigator-contribution'; import { UriCommandHandler, UriAwareCommandHandler } from '@theia/core/lib/common/uri-command-handler'; @@ -218,7 +218,9 @@ export class SearchInWorkspaceFrontendContribution extends AbstractViewContribut execute: () => this.withWidget(undefined, widget => { const { selection } = this.selectionService; if (TreeWidgetSelection.is(selection)) { - widget.resultTreeWidget.removeNode(selection[0]); + for (const selected of selection) { + widget.resultTreeWidget.removeNode(selected); + } } }) }); @@ -303,6 +305,11 @@ export class SearchInWorkspaceFrontendContribution extends AbstractViewContribut keybinding: 'shift+alt+f', when: 'explorerResourceIsFolder' }); + keybindings.registerKeybinding({ + command: SearchInWorkspaceCommands.DISMISS_RESULT.id, + keybinding: isOSX ? 'cmd+backspace' : 'del', + when: 'searchViewletFocus' + }); } override registerMenus(menus: MenuModelRegistry): void { diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-frontend-module.ts b/packages/search-in-workspace/src/browser/search-in-workspace-frontend-module.ts index f7e05bc371280..39aeecdbd102e 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-frontend-module.ts +++ b/packages/search-in-workspace/src/browser/search-in-workspace-frontend-module.ts @@ -74,6 +74,7 @@ export function createSearchTreeWidget(parent: interfaces.Container): SearchInWo widget: SearchInWorkspaceResultTreeWidget, props: { contextMenuPath: SearchInWorkspaceResultTreeWidget.Menus.BASE, + multiSelect: true, globalSelection: true } });