file search: include workspace folder in filter

"Go to File..." search can now filter files based on the workspace folder name.

This feature is activated only when the workspace contains more than one folder.

This is particularly useful when your workspace contains multiple files with the same name, each of them in another workspace folder.

A common example is the `README.md` file. Say you want to find a `README.md` file from a particular folder, say `my-folder`. Before this change you'd have to press the `Down` button a few times before you could get to the file.

With this change you'd instead search for `mfREADME.md`. The desired readme file should now appear closer to the top of the file search popup.
This commit is contained in:
Matej Urbas
2020-01-30 19:53:13 +00:00
parent 89cafb24e5
commit d4c2e7d8c5
8 changed files with 83 additions and 37 deletions

View File

@@ -12,7 +12,7 @@ import { isNative } from 'vs/base/common/platform';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILabelService } from 'vs/platform/label/common/label';
import { IFileMatch, IPatternInfo, ISearchProgressItem, ISearchService } from 'vs/workbench/services/search/common/search';
import { IWorkspaceContextService, WorkbenchState, IWorkspace } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceContextService, WorkbenchState, IWorkspace, toWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { ITextQueryBuilderOptions, QueryBuilder } from 'vs/workbench/contrib/search/common/queryBuilder';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -138,7 +138,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
}
const query = this._queryBuilder.file(
includeFolder ? [includeFolder] : workspace.folders.map(f => f.uri),
includeFolder ? [toWorkspaceFolder(includeFolder)] : workspace.folders,
{
maxResults: withNullAsUndefined(maxResults),
disregardExcludeSettings: (excludePatternOrDisregardExcludes === false) || undefined,
@@ -190,7 +190,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
$checkExists(folders: UriComponents[], includes: string[], token: CancellationToken): Promise<boolean> {
const queryBuilder = this._instantiationService.createInstance(QueryBuilder);
const query = queryBuilder.file(folders.map(folder => URI.revive(folder)), {
const query = queryBuilder.file(folders.map(folder => toWorkspaceFolder(URI.revive(folder))), {
_reason: 'checkExists',
includePattern: includes.join(', '),
expandPatterns: true,