Skip to content

Commit d7f814a

Browse files
authored
Add keybindings for search editor file filters (microsoft#153954)
* Add keybindings for search editor file filters * Review cleanup
1 parent 1b6ce58 commit d7f814a

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import { Disposable } from 'vs/base/common/lifecycle';
4141
const OpenInEditorCommandId = 'search.action.openInEditor';
4242
const OpenNewEditorToSideCommandId = 'search.action.openNewEditorToSide';
4343
const FocusQueryEditorWidgetCommandId = 'search.action.focusQueryEditorWidget';
44+
const FocusQueryEditorFilesToIncludeCommandId = 'search.action.focusFilesToInclude';
45+
const FocusQueryEditorFilesToExcludeCommandId = 'search.action.focusFilesToExclude';
4446

4547
const ToggleSearchEditorCaseSensitiveCommandId = 'toggleSearchEditorCaseSensitive';
4648
const ToggleSearchEditorWholeWordCommandId = 'toggleSearchEditorWholeWord';
@@ -374,6 +376,44 @@ registerAction2(class extends Action2 {
374376
}
375377
});
376378

379+
registerAction2(class extends Action2 {
380+
constructor() {
381+
super({
382+
id: FocusQueryEditorFilesToIncludeCommandId,
383+
title: { value: localize('search.action.focusFilesToInclude', "Focus Search Editor Files to Include"), original: 'Focus Search Editor Files to Include' },
384+
category,
385+
f1: true,
386+
precondition: SearchEditorConstants.InSearchEditor,
387+
});
388+
}
389+
async run(accessor: ServicesAccessor) {
390+
const editorService = accessor.get(IEditorService);
391+
const input = editorService.activeEditor;
392+
if (input instanceof SearchEditorInput) {
393+
(editorService.activeEditorPane as SearchEditor).focusFilesToIncludeInput();
394+
}
395+
}
396+
});
397+
398+
registerAction2(class extends Action2 {
399+
constructor() {
400+
super({
401+
id: FocusQueryEditorFilesToExcludeCommandId,
402+
title: { value: localize('search.action.focusFilesToExclude', "Focus Search Editor Files to Exclude"), original: 'Focus Search Editor Files to Exclude' },
403+
category,
404+
f1: true,
405+
precondition: SearchEditorConstants.InSearchEditor,
406+
});
407+
}
408+
async run(accessor: ServicesAccessor) {
409+
const editorService = accessor.get(IEditorService);
410+
const input = editorService.activeEditor;
411+
if (input instanceof SearchEditorInput) {
412+
(editorService.activeEditorPane as SearchEditor).focusFilesToExcludeInput();
413+
}
414+
}
415+
});
416+
377417
registerAction2(class extends Action2 {
378418
constructor() {
379419
super({

src/vs/workbench/contrib/searchEditor/browser/searchEditor.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,20 @@ export class SearchEditor extends AbstractTextCodeEditor<SearchEditorViewState>
275275
this.queryEditorWidget.searchInput.focus();
276276
}
277277

278+
focusFilesToIncludeInput() {
279+
if (!this.showingIncludesExcludes) {
280+
this.toggleIncludesExcludes(true);
281+
}
282+
this.inputPatternIncludes.focus();
283+
}
284+
285+
focusFilesToExcludeInput() {
286+
if (!this.showingIncludesExcludes) {
287+
this.toggleIncludesExcludes(true);
288+
}
289+
this.inputPatternExcludes.focus();
290+
}
291+
278292
focusNextInput() {
279293
if (this.queryEditorWidget.searchInputHasFocus()) {
280294
if (this.showingIncludesExcludes) {

0 commit comments

Comments
 (0)