Skip to content

Commit

Permalink
Merge pull request #26969 from nicksnyder/search
Browse files Browse the repository at this point in the history
Make SearchWidget dependencies injectable
  • Loading branch information
sandy081 committed May 22, 2017
2 parents 6e43693 + b8e4b7f commit 9536c27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/vs/workbench/parts/search/browser/searchViewlet.ts
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
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

0 comments on commit 9536c27

Please sign in to comment.