Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IAction instead of Action for search item action #164844

Merged
merged 1 commit into from Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/vs/workbench/contrib/search/browser/searchActions.ts
Expand Up @@ -5,7 +5,7 @@

import * as DOM from 'vs/base/browser/dom';
import { ITreeNavigator } from 'vs/base/browser/ui/tree/tree';
import { Action } from 'vs/base/common/actions';
import { Action, IAction } from 'vs/base/common/actions';
import { createKeybinding, ResolvedKeybinding } from 'vs/base/common/keybindings';
import { isWindows, OS } from 'vs/base/common/platform';
import * as nls from 'vs/nls';
Expand Down Expand Up @@ -420,21 +420,27 @@ class ReplaceActionRunner {
}
}

export class RemoveAction extends Action {
export class RemoveAction implements IAction {

static readonly LABEL = nls.localize('RemoveAction.label', "Dismiss");

readonly id = Constants.RemoveActionId;
public class = ThemeIcon.asClassName(searchRemoveIcon);
public label: string;
public tooltip = '';
public enabled = true;

constructor(
private viewer: WorkbenchCompressibleObjectTree<RenderableMatch>,
private element: RenderableMatch,
private readonly viewer: WorkbenchCompressibleObjectTree<RenderableMatch>,
private readonly element: RenderableMatch,
@IKeybindingService keyBindingService: IKeybindingService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IViewsService private readonly viewsService: IViewsService,
) {
super(Constants.RemoveActionId, appendKeyBindingLabel(RemoveAction.LABEL, keyBindingService.lookupKeybinding(Constants.RemoveActionId), keyBindingService), ThemeIcon.asClassName(searchRemoveIcon));
this.label = appendKeyBindingLabel(RemoveAction.LABEL, keyBindingService.lookupKeybinding(Constants.RemoveActionId), keyBindingService);
}

override async run(): Promise<any> {
run(): void {
const opInfo = getElementsToOperateOnInfo(this.viewer, this.element, this.configurationService.getValue<ISearchConfigurationProperties>('search'));
const elementsToRemove = opInfo.elements;
let focusElement = this.viewer.getFocus()[0];
Expand Down
Expand Up @@ -180,7 +180,6 @@ export class FolderMatchRenderer extends Disposable implements ICompressibleTree
}
const removeAction = this.instantiationService.createInstance(RemoveAction, this.searchView.getControl(), folder);
actions.push(removeAction);
templateData.disposableActions.add(removeAction);

templateData.actions.push(actions, { icon: true, label: false });
}
Expand Down