From 35b91522e736711680a558a7d801f30b5b69b039 Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Tue, 3 Oct 2017 11:55:48 -0700 Subject: [PATCH] Check search.useRipgrep for file searches (#34999) --- .../platform/telemetry/common/experiments.ts | 10 ++++------ .../electron-browser/mainThreadWorkspace.ts | 13 +++++++++---- src/vs/workbench/api/node/extHost.api.impl.ts | 6 ++++-- .../api/node/extHostExtensionService.ts | 10 ++++++++-- src/vs/workbench/node/extensionHostMain.ts | 18 +++++++++++++++--- .../parts/search/browser/openFileHandler.ts | 3 --- .../search/browser/search.contribution.ts | 2 +- .../parts/search/common/queryBuilder.ts | 2 +- .../quickopen.perf.integrationTest.ts | 4 +--- 9 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/vs/platform/telemetry/common/experiments.ts b/src/vs/platform/telemetry/common/experiments.ts index 82350aa22c6..fa40eff9876 100644 --- a/src/vs/platform/telemetry/common/experiments.ts +++ b/src/vs/platform/telemetry/common/experiments.ts @@ -14,7 +14,6 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' } */ export interface IExperiments { - ripgrepQuickSearch: boolean; } export const IExperimentService = createDecorator('experimentService'); @@ -30,7 +29,7 @@ export class ExperimentService implements IExperimentService { _serviceBrand: any; - private experiments: IExperiments; + private experiments: IExperiments = {}; // Shortcut while there are no experiments. constructor( @IStorageService private storageService: IStorageService, @@ -47,7 +46,6 @@ export class ExperimentService implements IExperimentService { function loadExperiments(storageService: IStorageService, configurationService: IConfigurationService): IExperiments { const experiments = splitExperimentsRandomness(storageService); - experiments.ripgrepQuickSearch = true; return applyOverrides(experiments, configurationService); } @@ -63,12 +61,12 @@ function applyOverrides(experiments: IExperiments, configurationService: IConfig function splitExperimentsRandomness(storageService: IStorageService): IExperiments { const random1 = getExperimentsRandomness(storageService); - const [random2, ripgrepQuickSearch] = splitRandom(random1); - const [/* random3 */, /* deployToAzureQuickLink */] = splitRandom(random2); + const [/* random2 */, /* ripgrepQuickSearch */] = splitRandom(random1); + // const [/* random3 */, /* deployToAzureQuickLink */] = splitRandom(random2); // const [random4, /* mergeQuickLinks */] = splitRandom(random3); // const [random5, /* enableWelcomePage */] = splitRandom(random4); return { - ripgrepQuickSearch, + // ripgrepQuickSearch, }; } diff --git a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts index 12777a683c8..69d00f909db 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts @@ -6,7 +6,7 @@ import { isPromiseCanceledError } from 'vs/base/common/errors'; import URI from 'vs/base/common/uri'; -import { ISearchService, QueryType, ISearchQuery, IFolderQuery } from 'vs/platform/search/common/search'; +import { ISearchService, QueryType, ISearchQuery, IFolderQuery, ISearchConfiguration } from 'vs/platform/search/common/search'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { TPromise } from 'vs/base/common/winjs.base'; @@ -14,7 +14,7 @@ import { MainThreadWorkspaceShape, ExtHostWorkspaceShape, ExtHostContext, MainCo import { IFileService } from 'vs/platform/files/common/files'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; -import { IExperimentService } from 'vs/platform/telemetry/common/experiments'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IRelativePattern } from 'vs/base/common/glob'; @extHostNamedCustomer(MainContext.MainThreadWorkspace) @@ -29,7 +29,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { @ISearchService private readonly _searchService: ISearchService, @IWorkspaceContextService private readonly _contextService: IWorkspaceContextService, @ITextFileService private readonly _textFileService: ITextFileService, - @IExperimentService private _experimentService: IExperimentService, + @IConfigurationService private _configurationService: IConfigurationService, @IFileService private readonly _fileService: IFileService ) { this._proxy = extHostContext.get(ExtHostContext.ExtHostWorkspace); @@ -67,13 +67,18 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape { folderQueries = [{ folder: URI.file(include.base) }]; // relative pattern: search only in base folder } + const useRipgrep = folderQueries.every(folderQuery => { + const folderConfig = this._configurationService.getConfiguration(undefined, { resource: folderQuery.folder }); + return folderConfig.search.useRipgrep; + }); + const query: ISearchQuery = { folderQueries, type: QueryType.File, maxResults, includePattern: { [typeof include === 'string' ? include : !!include ? include.pattern : undefined]: true }, excludePattern: { [typeof exclude === 'string' ? exclude : !!exclude ? exclude.pattern : undefined]: true }, - useRipgrep: this._experimentService.getExperiments().ripgrepQuickSearch + useRipgrep }; this._searchService.extendQuery(query); diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 907abd5c9e6..b5423526507 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -76,6 +76,8 @@ function proposedApiFunction(extension: IExtensionDescription, fn: T): T { export function createApiFactory( initData: IInitData, threadService: ExtHostThreadService, + extHostWorkspace: ExtHostWorkspace, + extHostConfiguration: ExtHostConfiguration, extensionService: ExtHostExtensionService ): IExtensionApiFactory { @@ -90,9 +92,9 @@ export function createApiFactory( const extHostEditors = threadService.set(ExtHostContext.ExtHostEditors, new ExtHostEditors(threadService, extHostDocumentsAndEditors)); const extHostCommands = threadService.set(ExtHostContext.ExtHostCommands, new ExtHostCommands(threadService, extHostHeapService)); const extHostTreeViews = threadService.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(threadService.get(MainContext.MainThreadTreeViews), extHostCommands)); - const extHostWorkspace = threadService.set(ExtHostContext.ExtHostWorkspace, new ExtHostWorkspace(threadService, initData.workspace)); + threadService.set(ExtHostContext.ExtHostWorkspace, extHostWorkspace); const extHostDebugService = threadService.set(ExtHostContext.ExtHostDebugService, new ExtHostDebugService(threadService, extHostWorkspace)); - const extHostConfiguration = threadService.set(ExtHostContext.ExtHostConfiguration, new ExtHostConfiguration(threadService.get(MainContext.MainThreadConfiguration), extHostWorkspace, initData.configuration)); + threadService.set(ExtHostContext.ExtHostConfiguration, extHostConfiguration); const extHostDiagnostics = threadService.set(ExtHostContext.ExtHostDiagnostics, new ExtHostDiagnostics(threadService)); const languageFeatures = threadService.set(ExtHostContext.ExtHostLanguageFeatures, new ExtHostLanguageFeatures(threadService, extHostDocuments, extHostCommands, extHostHeapService, extHostDiagnostics)); const extHostFileSystem = threadService.set(ExtHostContext.ExtHostFileSystem, new ExtHostFileSystem(threadService)); diff --git a/src/vs/workbench/api/node/extHostExtensionService.ts b/src/vs/workbench/api/node/extHostExtensionService.ts index 513d6d27504..809a99ec59b 100644 --- a/src/vs/workbench/api/node/extHostExtensionService.ts +++ b/src/vs/workbench/api/node/extHostExtensionService.ts @@ -17,6 +17,8 @@ import { MainContext, MainThreadExtensionServiceShape, IWorkspaceData, IEnvironm import { IExtensionMemento, ExtensionsActivator, ActivatedExtension, IExtensionAPI, IExtensionContext, EmptyExtension, IExtensionModule, ExtensionActivationTimesBuilder, ExtensionActivationTimes } from 'vs/workbench/api/node/extHostExtensionActivator'; import { Barrier } from 'vs/workbench/services/extensions/node/barrier'; import { ExtHostThreadService } from 'vs/workbench/services/thread/node/extHostThreadService'; +import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration'; +import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace'; import { realpath } from 'fs'; import { TernarySearchTree } from 'vs/base/common/map'; @@ -120,7 +122,11 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape { /** * This class is constructed manually because it is a service, so it doesn't use any ctor injection */ - constructor(initData: IInitData, threadService: ExtHostThreadService) { + constructor(initData: IInitData, + threadService: ExtHostThreadService, + extHostWorkspace: ExtHostWorkspace, + extHostConfiguration: ExtHostConfiguration + ) { this._barrier = new Barrier(); this._registry = new ExtensionDescriptionRegistry(initData.extensions); this._threadService = threadService; @@ -131,7 +137,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape { this._activator = null; // initialize API first (i.e. do not release barrier until the API is initialized) - const apiFactory = createApiFactory(initData, threadService, this); + const apiFactory = createApiFactory(initData, threadService, extHostWorkspace, extHostConfiguration, this); initializeExtensionApi(this, apiFactory).then(() => { diff --git a/src/vs/workbench/node/extensionHostMain.ts b/src/vs/workbench/node/extensionHostMain.ts index c08dd047c5d..cda0a718027 100644 --- a/src/vs/workbench/node/extensionHostMain.ts +++ b/src/vs/workbench/node/extensionHostMain.ts @@ -12,6 +12,8 @@ import { join } from 'path'; import { RPCProtocol } from 'vs/workbench/services/extensions/node/rpcProtocol'; import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionService'; import { ExtHostThreadService } from 'vs/workbench/services/thread/node/extHostThreadService'; +import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration'; +import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace'; import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; import { QueryType, ISearchQuery } from 'vs/platform/search/common/search'; import { DiskSearch } from 'vs/workbench/services/search/node/searchService'; @@ -58,6 +60,7 @@ export class ExtensionHostMain { private _workspace: IWorkspaceData; private _environment: IEnvironment; private _extensionService: ExtHostExtensionService; + private _extHostConfiguration: ExtHostConfiguration; constructor(rpcProtocol: RPCProtocol, initData: IInitData) { this._environment = initData.environment; @@ -65,7 +68,9 @@ export class ExtensionHostMain { // services const threadService = new ExtHostThreadService(rpcProtocol); - this._extensionService = new ExtHostExtensionService(initData, threadService); + const extHostWorkspace = new ExtHostWorkspace(threadService, initData.workspace); + this._extHostConfiguration = new ExtHostConfiguration(threadService.get(MainContext.MainThreadConfiguration), extHostWorkspace, initData.configuration); + this._extensionService = new ExtHostExtensionService(initData, threadService, extHostWorkspace, this._extHostConfiguration); // error forwarding and stack trace scanning const extensionErrors = new WeakMap(); @@ -218,11 +223,18 @@ export class ExtensionHostMain { includes[globPattern] = true; }); + const folderQueries = this._workspace.folders.map(folder => ({ folder: folder.uri })); + const useRipgrep = folderQueries.every(folderQuery => { + const folderConfig = this._extHostConfiguration.getConfiguration('search', folderQuery.folder); + return folderConfig.get('useRipgrep', true); + }); + const query: ISearchQuery = { - folderQueries: this._workspace.folders.map(folder => ({ folder: folder.uri })), + folderQueries, type: QueryType.File, maxResults: 1, - includePattern: includes + includePattern: includes, + useRipgrep }; let result = await this._diskSearch.search(query); diff --git a/src/vs/workbench/parts/search/browser/openFileHandler.ts b/src/vs/workbench/parts/search/browser/openFileHandler.ts index 2e8df19f0b7..914dd416440 100644 --- a/src/vs/workbench/parts/search/browser/openFileHandler.ts +++ b/src/vs/workbench/parts/search/browser/openFileHandler.ts @@ -32,7 +32,6 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IRange } from 'vs/editor/common/core/range'; import { getOutOfWorkspaceEditorResources } from 'vs/workbench/parts/search/common/search'; -import { IExperimentService } from 'vs/platform/telemetry/common/experiments'; export class FileQuickOpenModel extends QuickOpenModel { @@ -123,7 +122,6 @@ export class OpenFileHandler extends QuickOpenHandler { @IWorkbenchThemeService private themeService: IWorkbenchThemeService, @IWorkspaceContextService private contextService: IWorkspaceContextService, @ISearchService private searchService: ISearchService, - @IExperimentService private experimentService: IExperimentService, @IEnvironmentService private environmentService: IEnvironmentService ) { super(); @@ -196,7 +194,6 @@ export class OpenFileHandler extends QuickOpenHandler { cacheKey: cacheKey, maxResults: 0, sortByScore: true, - useRipgrep: this.experimentService.getExperiments().ripgrepQuickSearch }; const folderResources = this.contextService.getWorkspace().folders.map(folder => folder.uri); diff --git a/src/vs/workbench/parts/search/browser/search.contribution.ts b/src/vs/workbench/parts/search/browser/search.contribution.ts index e23ac05ad1f..5c489ff6e63 100644 --- a/src/vs/workbench/parts/search/browser/search.contribution.ts +++ b/src/vs/workbench/parts/search/browser/search.contribution.ts @@ -359,7 +359,7 @@ configurationRegistry.registerConfiguration({ }, 'search.useRipgrep': { 'type': 'boolean', - 'description': nls.localize('useRipgrep', "Controls whether to use ripgrep in text search"), + 'description': nls.localize('useRipgrep', "Controls whether to use ripgrep in text and file search"), 'default': true }, 'search.useIgnoreFilesByDefault': { diff --git a/src/vs/workbench/parts/search/common/queryBuilder.ts b/src/vs/workbench/parts/search/common/queryBuilder.ts index 014ad87db11..9b3120dcdc6 100644 --- a/src/vs/workbench/parts/search/common/queryBuilder.ts +++ b/src/vs/workbench/parts/search/common/queryBuilder.ts @@ -55,7 +55,7 @@ export class QueryBuilder { } } - const useRipgrep = type === QueryType.File ? options.useRipgrep : !folderResources || folderResources.every(folder => { + const useRipgrep = !folderResources || folderResources.every(folder => { const folderConfig = this.configurationService.getConfiguration(undefined, { resource: folder }); return folderConfig.search.useRipgrep; }); diff --git a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts index 67fd26bdfbc..f811c0727c3 100644 --- a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts @@ -185,8 +185,6 @@ class TestExperimentService implements IExperimentService { _serviceBrand: any; getExperiments(): IExperiments { - return { - ripgrepQuickSearch: true, - }; + return {}; } } -- GitLab