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

Make SearchWidget dependencies injectable #26969

Merged
merged 1 commit into from
May 22, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/vs/workbench/parts/search/browser/searchViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IMessageService } from 'vs/platform/message/common/message';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { KeyCode } from 'vs/base/common/keyCodes';
import { PatternInputWidget, ExcludePatternInputWidget } from 'vs/workbench/parts/search/browser/patternInputWidget';
import { SearchRenderer, SearchDataSource, SearchSorter, SearchAccessibilityProvider, SearchFilter } from 'vs/workbench/parts/search/browser/searchResultsView';
import { SearchWidget } from 'vs/workbench/parts/search/browser/searchWidget';
import { SearchWidget, ISearchWidgetOptions } from 'vs/workbench/parts/search/browser/searchWidget';
import { RefreshAction, CollapseAllAction, ClearSearchResultsAction, ConfigureGlobalExclusionsAction } from 'vs/workbench/parts/search/browser/searchActions';
import { IReplaceService } from 'vs/workbench/parts/search/common/replace';
import Severity from 'vs/base/common/severity';
Expand Down Expand Up @@ -117,7 +116,6 @@ export class SearchViewlet extends Viewlet {
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@ISearchWorkbenchService private searchWorkbenchService: ISearchWorkbenchService,
@IContextKeyService private contextKeyService: IContextKeyService,
@IKeybindingService private keybindingService: IKeybindingService,
@IReplaceService private replaceService: IReplaceService,
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
@IPreferencesService private preferencesService: IPreferencesService,
Expand Down Expand Up @@ -290,12 +288,12 @@ export class SearchViewlet extends Viewlet {
let isWholeWords = this.viewletSettings['query.wholeWords'] === true;
let isCaseSensitive = this.viewletSettings['query.caseSensitive'] === true;

this.searchWidget = new SearchWidget(builder, this.contextViewService, this.themeService, {
this.searchWidget = this.instantiationService.createInstance(SearchWidget, builder, <ISearchWidgetOptions>{
value: contentPattern,
isRegex: isRegex,
isCaseSensitive: isCaseSensitive,
isWholeWords: isWholeWords
}, this.contextKeyService, this.keybindingService, this.instantiationService);
});

if (this.storageService.getBoolean(SearchViewlet.SHOW_REPLACE_STORAGE_KEY, StorageScope.WORKSPACE, true)) {
this.searchWidget.toggleReplace(true);
Expand Down
11 changes: 8 additions & 3 deletions src/vs/workbench/parts/search/browser/searchWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import Event, { Emitter } from 'vs/base/common/event';
import { Builder } from 'vs/base/browser/builder';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { isSearchViewletFocussed, appendKeyBindingLabel } from 'vs/workbench/parts/search/browser/searchActions';
import { CONTEXT_FIND_WIDGET_NOT_VISIBLE } from 'vs/editor/contrib/find/common/findController';
Expand Down Expand Up @@ -111,8 +110,14 @@ export class SearchWidget extends Widget {
private _onReplaceAll = this._register(new Emitter<void>());
public onReplaceAll: Event<void> = this._onReplaceAll.event;

constructor(container: Builder, private contextViewService: IContextViewService, private themeService: IThemeService, options: ISearchWidgetOptions = Object.create(null),
private keyBindingService: IContextKeyService, private keyBindingService2: IKeybindingService, private instantiationService: IInstantiationService) {
constructor(
container: Builder,
options: ISearchWidgetOptions,
@IContextViewService private contextViewService: IContextViewService,
@IThemeService private themeService: IThemeService,
@IContextKeyService private keyBindingService: IContextKeyService,
@IKeybindingService private keyBindingService2: IKeybindingService,
) {
super();
this.searchHistory = new HistoryNavigator<string>();
this.replaceActive = Constants.ReplaceActiveKey.bindTo(this.keyBindingService);
Expand Down