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

search-in-workspace: focus on next and previous search results #12703

Merged
merged 12 commits into from
Feb 8, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ export namespace SearchInWorkspaceCommands {
category: SEARCH_CATEGORY,
label: 'Find in Folder...'
});
export const FOCUS_NEXT_RESULT = Command.toDefaultLocalizedCommand({
id: 'search-in-workspace.next-result',
category: SEARCH_CATEGORY,
label: 'Focus Next Search Result'
});
export const FOCUS_PREV_RESULT = Command.toDefaultLocalizedCommand({
id: 'search-in-workspace.prev-result',
vladarama marked this conversation as resolved.
Show resolved Hide resolved
category: SEARCH_CATEGORY,
label: 'Focus Previous Search Result'
});
export const REFRESH_RESULTS = Command.toDefaultLocalizedCommand({
id: 'search-in-workspace.refresh',
category: SEARCH_CATEGORY,
Expand Down Expand Up @@ -169,6 +179,20 @@ export class SearchInWorkspaceFrontendContribution extends AbstractViewContribut
}
});

commands.registerCommand(SearchInWorkspaceCommands.FOCUS_NEXT_RESULT, {
execute: async () => {
const widget = await this.openView({ activate: true });
widget.resultTreeWidget.model.selectNextNode();
}
});

commands.registerCommand(SearchInWorkspaceCommands.FOCUS_PREV_RESULT, {
execute: async () => {
const widget = await this.openView({ activate: true });
widget.resultTreeWidget.model.selectPrevNode();
}
});

commands.registerCommand(SearchInWorkspaceCommands.FIND_IN_FOLDER, this.newMultiUriAwareCommandHandler({
execute: async uris => {
const resources: string[] = [];
Expand Down Expand Up @@ -343,6 +367,14 @@ export class SearchInWorkspaceFrontendContribution extends AbstractViewContribut
keybinding: 'shift+alt+f',
when: 'explorerResourceIsFolder'
});
keybindings.registerKeybinding({
command: SearchInWorkspaceCommands.FOCUS_NEXT_RESULT.id,
keybinding: 'f4',
});
keybindings.registerKeybinding({
command: SearchInWorkspaceCommands.FOCUS_PREV_RESULT.id,
keybinding: 'shift+f4',
});
vladarama marked this conversation as resolved.
Show resolved Hide resolved
keybindings.registerKeybinding({
command: SearchInWorkspaceCommands.DISMISS_RESULT.id,
keybinding: isOSX ? 'cmd+backspace' : 'del',
Expand Down Expand Up @@ -376,9 +408,17 @@ export class SearchInWorkspaceFrontendContribution extends AbstractViewContribut
order: '2'
});
menus.registerMenuAction(CommonMenus.EDIT_FIND, {
commandId: SearchInWorkspaceCommands.REPLACE_IN_FILES.id,
commandId: SearchInWorkspaceCommands.FOCUS_NEXT_RESULT.id,
order: '3'
});
menus.registerMenuAction(CommonMenus.EDIT_FIND, {
commandId: SearchInWorkspaceCommands.FOCUS_PREV_RESULT.id,
order: '4'
});
menus.registerMenuAction(CommonMenus.EDIT_FIND, {
commandId: SearchInWorkspaceCommands.REPLACE_IN_FILES.id,
order: '5'
});
vladarama marked this conversation as resolved.
Show resolved Hide resolved
menus.registerMenuAction(SearchInWorkspaceResultTreeWidget.Menus.INTERNAL, {
commandId: SearchInWorkspaceCommands.REPLACE_RESULT.id,
label: nls.localizeByDefault('Replace'),
Expand Down