Skip to content

Commit

Permalink
Add command to rerun search editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Kearl committed Jan 25, 2020
1 parent a3c5a15 commit ad29830
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { ExplorerFolderContext, ExplorerRootContext, FilesExplorerFocusCondition
import { OpenAnythingHandler } from 'vs/workbench/contrib/search/browser/openAnythingHandler';
import { OpenSymbolHandler } from 'vs/workbench/contrib/search/browser/openSymbolHandler';
import { registerContributions as replaceContributions } from 'vs/workbench/contrib/search/browser/replaceContributions';
import { clearHistoryCommand, ClearSearchResultsAction, CloseReplaceAction, CollapseDeepestExpandedLevelAction, copyAllCommand, copyMatchCommand, copyPathCommand, FocusNextInputAction, FocusNextSearchResultAction, FocusPreviousInputAction, FocusPreviousSearchResultAction, focusSearchListCommand, getSearchView, openSearchView, OpenSearchViewletAction, RefreshAction, RemoveAction, ReplaceAction, ReplaceAllAction, ReplaceAllInFolderAction, ReplaceInFilesAction, toggleCaseSensitiveCommand, toggleRegexCommand, toggleWholeWordCommand, FindInFilesCommand, ToggleSearchOnTypeAction, OpenResultsInEditorAction, ExpandAllAction, OpenSearchEditorAction, toggleSearchEditorCaseSensitiveCommand, toggleSearchEditorWholeWordCommand, toggleSearchEditorRegexCommand, toggleSearchEditorContextLinesCommand } from 'vs/workbench/contrib/search/browser/searchActions';
import { clearHistoryCommand, ClearSearchResultsAction, CloseReplaceAction, CollapseDeepestExpandedLevelAction, copyAllCommand, copyMatchCommand, copyPathCommand, FocusNextInputAction, FocusNextSearchResultAction, FocusPreviousInputAction, FocusPreviousSearchResultAction, focusSearchListCommand, getSearchView, openSearchView, OpenSearchViewletAction, RefreshAction, RemoveAction, ReplaceAction, ReplaceAllAction, ReplaceAllInFolderAction, ReplaceInFilesAction, toggleCaseSensitiveCommand, toggleRegexCommand, toggleWholeWordCommand, FindInFilesCommand, ToggleSearchOnTypeAction, OpenResultsInEditorAction, ExpandAllAction, OpenSearchEditorAction, toggleSearchEditorCaseSensitiveCommand, toggleSearchEditorWholeWordCommand, toggleSearchEditorRegexCommand, toggleSearchEditorContextLinesCommand, ReRunSearchEditorSearchAction } from 'vs/workbench/contrib/search/browser/searchActions';
import { SearchView } from 'vs/workbench/contrib/search/browser/searchView';
import { registerContributions as searchWidgetContributions } from 'vs/workbench/contrib/search/browser/searchWidget';
import * as Constants from 'vs/workbench/contrib/search/common/constants';
Expand Down Expand Up @@ -641,6 +641,12 @@ registry.registerWorkbenchAction(SyncActionDescriptor.create(ToggleSearchOnTypeA
registry.registerWorkbenchAction(SyncActionDescriptor.create(RefreshAction, RefreshAction.ID, RefreshAction.LABEL), 'Search: Refresh', category);
registry.registerWorkbenchAction(SyncActionDescriptor.create(ClearSearchResultsAction, ClearSearchResultsAction.ID, ClearSearchResultsAction.LABEL), 'Search: Clear Search Results', category);


registry.registerWorkbenchAction(
SyncActionDescriptor.create(ReRunSearchEditorSearchAction, ReRunSearchEditorSearchAction.ID, ReRunSearchEditorSearchAction.LABEL),
'Search Editor: Rerun search', category, ContextKeyExpr.and(Constants.InSearchEditor)
);

registry.registerWorkbenchAction(
SyncActionDescriptor.create(OpenResultsInEditorAction, OpenResultsInEditorAction.ID, OpenResultsInEditorAction.LABEL,
{ mac: { primary: KeyMod.CtrlCmd | KeyCode.Enter } },
Expand Down
20 changes: 20 additions & 0 deletions src/vs/workbench/contrib/search/browser/searchActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,26 @@ export class OpenResultsInEditorAction extends Action {
}


export class ReRunSearchEditorSearchAction extends Action {

static readonly ID = 'searchEditor.rerunSerach';
static readonly LABEL = nls.localize('search.rerunSearch', "Rerun Search in Editor");

constructor(id: string, label: string,
@IEditorService private readonly editorService: IEditorService) {
super(id, label);
}

async run() {
const input = this.editorService.activeEditor;
if (input instanceof SearchEditorInput) {
await (this.editorService.activeControl as SearchEditor).runSearch();
}
}
}



export class FocusNextSearchResultAction extends Action {
static readonly ID = 'search.action.focusNextSearchResult';
static readonly LABEL = nls.localize('FocusNextSearchResult.label', "Focus Next Search Result");
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/search/browser/searchEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export class SearchEditor extends BaseEditor {
this.queryEditorWidget.toggleContextLines();
}

private async runSearch(instant = false) {
async runSearch(instant = false) {
if (!this.pauseSearching) {
this.runSearchDelayer.trigger(() => this.doRunSearch(), instant ? 0 : undefined);
}
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/search/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const ToggleSearchEditorCaseSensitiveCommandId = 'toggleSearchEditorCaseS
export const ToggleSearchEditorWholeWordCommandId = 'toggleSearchEditorWholeWord';
export const ToggleSearchEditorRegexCommandId = 'toggleSearchEditorRegex';
export const ToggleSearchEditorContextLinesCommandId = 'toggleSearchEditorContextLines';
export const RerunSearchEditorSearchCommandId = 'rerunSearchEditorSearch';
export const AddCursorsAtSearchResults = 'addCursorsAtSearchResults';
export const RevealInSideBarForSearchResults = 'search.action.revealInSideBar';

Expand Down

0 comments on commit ad29830

Please sign in to comment.