diff --git a/src/vs/platform/extensions/common/extensionsApiProposals.ts b/src/vs/platform/extensions/common/extensionsApiProposals.ts index 62e06494baf..cddb8687c0f 100644 --- a/src/vs/platform/extensions/common/extensionsApiProposals.ts +++ b/src/vs/platform/extensions/common/extensionsApiProposals.ts @@ -15,6 +15,9 @@ const _allApiProposals = { aiTextSearchProvider: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.aiTextSearchProvider.d.ts', }, + aiTextSearchProviderNew: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.aiTextSearchProviderNew.d.ts', + }, attributableCoverage: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.attributableCoverage.d.ts', }, @@ -193,12 +196,21 @@ const _allApiProposals = { fileSearchProvider: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fileSearchProvider.d.ts', }, + fileSearchProviderNew: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fileSearchProviderNew.d.ts', + }, findFiles2: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findFiles2.d.ts', }, + findFiles2New: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findFiles2New.d.ts', + }, findTextInFiles: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findTextInFiles.d.ts', }, + findTextInFilesNew: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts', + }, fsChunks: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fsChunks.d.ts', }, @@ -353,9 +365,15 @@ const _allApiProposals = { testObserver: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testObserver.d.ts', }, + textSearchCompleteNew: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchCompleteNew.d.ts', + }, textSearchProvider: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProvider.d.ts', }, + textSearchProviderNew: { + proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProviderNew.d.ts', + }, timeline: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.timeline.d.ts', }, diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 3b1577444a8..85c7ba9122a 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -3,10 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { AsyncIterableObject } from 'vs/base/common/async'; import { CancellationTokenSource } from 'vs/base/common/cancellation'; import * as errors from 'vs/base/common/errors'; import { Emitter, Event } from 'vs/base/common/event'; -import { combinedDisposable } from 'vs/base/common/lifecycle'; +import { combinedDisposable, IDisposable } from 'vs/base/common/lifecycle'; import { Schemas, matchesScheme } from 'vs/base/common/network'; import Severity from 'vs/base/common/severity'; import { URI } from 'vs/base/common/uri'; @@ -106,7 +107,7 @@ import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/c import { UIKind } from 'vs/workbench/services/extensions/common/extensionHostProtocol'; import { checkProposedApiEnabled, isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions'; import { ProxyIdentifier } from 'vs/workbench/services/extensions/common/proxyIdentifier'; -import { TextSearchCompleteMessageType } from 'vs/workbench/services/search/common/searchExtTypes'; +import { ExcludeSettingOptions, TextSearchCompleteMessageType, TextSearchCompleteMessageTypeNew, TextSearchContextNew, TextSearchMatchNew } from 'vs/workbench/services/search/common/searchExtTypes'; import type * as vscode from 'vscode'; export interface IExtensionRegistries { @@ -966,10 +967,14 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I // Note, undefined/null have different meanings on "exclude" return extHostWorkspace.findFiles(include, exclude, maxResults, extension.identifier, token); }, - findFiles2: (filePattern, options?, token?) => { + findFiles2: (filePattern: vscode.GlobPattern, options?: vscode.FindFiles2Options, token?: vscode.CancellationToken): Thenable => { checkProposedApiEnabled(extension, 'findFiles2'); return extHostWorkspace.findFiles2(filePattern, options, extension.identifier, token); }, + findFiles2New: (filePattern: vscode.GlobPattern[], options?: vscode.FindFiles2OptionsNew, token?: vscode.CancellationToken): Thenable => { + checkProposedApiEnabled(extension, 'findFiles2New'); + return Promise.resolve([]); + }, findTextInFiles: (query: vscode.TextSearchQuery, optionsOrCallback: vscode.FindTextInFilesOptions | ((result: vscode.TextSearchResult) => void), callbackOrToken?: vscode.CancellationToken | ((result: vscode.TextSearchResult) => void), token?: vscode.CancellationToken) => { checkProposedApiEnabled(extension, 'findTextInFiles'); let options: vscode.FindTextInFilesOptions; @@ -986,6 +991,15 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostWorkspace.findTextInFiles(query, options || {}, callback, extension.identifier, token); }, + findTextInFilesNew: (query: vscode.TextSearchQueryNew, options?: vscode.FindTextInFilesOptionsNew, token?: vscode.CancellationToken): vscode.FindTextInFilesResponse => { + checkProposedApiEnabled(extension, 'findTextInFilesNew'); + return { + results: AsyncIterableObject.fromArray([]), + complete: Promise.resolve({ + limitHit: false + }) + }; + }, save: (uri) => { return extHostWorkspace.save(uri); }, @@ -1134,6 +1148,20 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I checkProposedApiEnabled(extension, 'textSearchProvider'); return extHostSearch.registerAITextSearchProvider(scheme, provider); }, + registerFileSearchProviderNew: (scheme: string, provider: vscode.FileSearchProviderNew) => { + checkProposedApiEnabled(extension, 'fileSearchProviderNew'); + return { dispose: () => { } }; + }, + registerTextSearchProviderNew: (scheme: string, provider: vscode.TextSearchProviderNew) => { + checkProposedApiEnabled(extension, 'textSearchProviderNew'); + return { dispose: () => { } }; + }, + registerAITextSearchProviderNew: (scheme: string, provider: vscode.AITextSearchProviderNew) => { + // there are some dependencies on textSearchProvider, so we need to check for both + checkProposedApiEnabled(extension, 'aiTextSearchProviderNew'); + checkProposedApiEnabled(extension, 'textSearchProviderNew'); + return { dispose: () => { } }; + }, registerRemoteAuthorityResolver: (authorityPrefix: string, resolver: vscode.RemoteAuthorityResolver) => { checkProposedApiEnabled(extension, 'resolvers'); return extensionService.registerRemoteAuthorityResolver(authorityPrefix, resolver); @@ -1758,6 +1786,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I NewSymbolNameTriggerKind: extHostTypes.NewSymbolNameTriggerKind, InlineEdit: extHostTypes.InlineEdit, InlineEditTriggerKind: extHostTypes.InlineEditTriggerKind, + ExcludeSettingOptions: ExcludeSettingOptions, + TextSearchContextNew: TextSearchContextNew, + TextSearchMatchNew: TextSearchMatchNew, + TextSearchCompleteMessageTypeNew: TextSearchCompleteMessageTypeNew, }; }; } diff --git a/src/vs/workbench/services/search/common/searchExtTypes.ts b/src/vs/workbench/services/search/common/searchExtTypes.ts index 48da6b3f96d..2c26e6e9abb 100644 --- a/src/vs/workbench/services/search/common/searchExtTypes.ts +++ b/src/vs/workbench/services/search/common/searchExtTypes.ts @@ -498,3 +498,60 @@ export interface FindTextInFilesOptions { */ afterContext?: number; } + +// NEW TYPES +// added temporarily for testing new API shape + +/** + * The main match information for a {@link TextSearchResultNew}. + */ +export class TextSearchMatchNew { + /** + * @param uri The uri for the matching document. + * @param ranges The ranges associated with this match. + * @param previewText The text that is used to preview the match. The highlighted range in `previewText` is specified in `ranges`. + */ + constructor( + public uri: URI, + public ranges: { sourceRange: Range; previewRange: Range }[], + public previewText: string) { } + +} + +/** + * The potential context information for a {@link TextSearchResultNew}. + */ +export class TextSearchContextNew { + /** + * @param uri The uri for the matching document. + * @param text The line of context text. + * @param lineNumber The line number of this line of context. + */ + constructor( + public uri: URI, + public text: string, + public lineNumber: number) { } +} + +export enum ExcludeSettingOptions { + /* + * Don't use any exclude settings. + */ + none = 1, + /* + * Use: + * - files.exclude setting + */ + filesExclude = 2, + /* + * Use: + * - files.exclude setting + * - search.exclude setting + */ + searchAndFilesExclude = 3 +} + +export enum TextSearchCompleteMessageTypeNew { + Information = 1, + Warning = 2, +} diff --git a/src/vscode-dts/vscode.proposed.aiTextSearchProviderNew.d.ts b/src/vscode-dts/vscode.proposed.aiTextSearchProviderNew.d.ts new file mode 100644 index 00000000000..d18010c77f2 --- /dev/null +++ b/src/vscode-dts/vscode.proposed.aiTextSearchProviderNew.d.ts @@ -0,0 +1,119 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + /** + * Options that apply to AI text search. + */ + export interface AITextSearchOptionsNew { + + folderOptions: { + /** + * The root folder to search within. + */ + folder: Uri; + + /** + * Files that match an `includes` glob pattern should be included in the search. + */ + includes: string[]; + + /** + * Files that match an `excludes` glob pattern should be excluded from the search. + */ + excludes: GlobPattern[]; + + /** + * Whether symlinks should be followed while searching. + * For more info, see the setting description for `search.followSymlinks`. + */ + followSymlinks: boolean; + + /** + * Which file locations we should look for ignore (.gitignore or .ignore) files to respect. + */ + useIgnoreFiles: { + /** + * Use ignore files at the current workspace root. + */ + local: boolean; + /** + * Use ignore files at the parent directory. If set, {@link TextSearchProviderOptionsNew.useIgnoreFiles.local} should also be `true`. + */ + parent: boolean; + /** + * Use global ignore files. If set, {@link TextSearchProviderOptionsNew.useIgnoreFiles.local} should also be `true`. + */ + global: boolean; + }; + }[]; + + /** + * The maximum number of results to be returned. + */ + maxResults: number; + + /** + * Options to specify the size of the result text preview. + */ + previewOptions: { + /** + * The maximum number of lines in the preview. + * Only search providers that support multiline search will ever return more than one line in the match. + */ + matchLines: number; + + /** + * The maximum number of characters included per line. + */ + charsPerLine: number; + }; + + /** + * Exclude files larger than `maxFileSize` in bytes. + */ + maxFileSize: number; + + /** + * Interpret files using this encoding. + * See the vscode setting `"files.encoding"` + */ + encoding: string; + + /** + * Number of lines of context to include before and after each match. + */ + surroundingContext: number; + } + + /** + * An AITextSearchProvider provides additional AI text search results in the workspace. + */ + export interface AITextSearchProviderNew { + /** + * WARNING: VERY EXPERIMENTAL. + * + * Provide results that match the given text pattern. + * @param query The parameter for this query. + * @param options A set of options to consider while searching. + * @param progress A progress callback that must be invoked for all results. + * @param token A cancellation token. + */ + provideAITextSearchResults(query: string, options: AITextSearchOptionsNew, progress: Progress, token: CancellationToken): ProviderResult; + } + + export namespace workspace { + /** + * Register an AI text search provider. + * + * Only one provider can be registered per scheme. + * + * @param scheme The provider will be invoked for workspace folders that have this file scheme. + * @param provider The provider. + * @return A {@link Disposable} that unregisters this provider when being disposed. + */ + export function registerAITextSearchProviderNew(scheme: string, provider: AITextSearchProviderNew): Disposable; + } +} diff --git a/src/vscode-dts/vscode.proposed.fileSearchProviderNew.d.ts b/src/vscode-dts/vscode.proposed.fileSearchProviderNew.d.ts new file mode 100644 index 00000000000..ad5a9d1d86e --- /dev/null +++ b/src/vscode-dts/vscode.proposed.fileSearchProviderNew.d.ts @@ -0,0 +1,100 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + // https://github.com/microsoft/vscode/issues/73524 + + /** + * Options that apply to file search. + */ + export interface FileSearchProviderOptionsNew { + folderOptions: { + /** + * The root folder to search within. + */ + folder: Uri; + + /** + * Files that match an `includes` glob pattern should be included in the search. + */ + includes: string[]; + + /** + * Files that match an `excludes` glob pattern should be excluded from the search. + */ + excludes: GlobPattern[]; + + /** + * Whether symlinks should be followed while searching. + * For more info, see the setting description for `search.followSymlinks`. + */ + followSymlinks: boolean; + + /** + * Which file locations we should look for ignore (.gitignore or .ignore) files to respect. + */ + useIgnoreFiles: { + /** + * Use ignore files at the current workspace root. + */ + local: boolean; + /** + * Use ignore files at the parent directory. If set, {@link FileSearchProviderOptionsNew.useIgnoreFiles.local} should also be `true`. + */ + parent: boolean; + /** + * Use global ignore files. If set, {@link FileSearchProviderOptionsNew.useIgnoreFiles.local} should also be `true`. + */ + global: boolean; + }; + }[]; + + /** + * An object with a lifespan that matches the session's lifespan. If the provider chooses to, this object can be used as the key for a cache, + * and searches with the same session object can search the same cache. When the token is cancelled, the session is complete and the cache can be cleared. + */ + session: unknown; + + /** + * The maximum number of results to be returned. + */ + maxResults: number; + } + + /** + * A FileSearchProvider provides search results for files in the given folder that match a query string. It can be invoked by quickopen or other extensions. + * + * A FileSearchProvider is the more powerful of two ways to implement file search in the editor. Use a FileSearchProvider if you wish to search within a folder for + * all files that match the user's query. + * + * The FileSearchProvider will be invoked on every keypress in quickopen. + */ + export interface FileSearchProviderNew { + /** + * WARNING: VERY EXPERIMENTAL. + * + * Provide the set of files that match a certain file path pattern. + * @param pattern The search pattern to match against file paths. + * @param options A set of options to consider while searching files. + * @param token A cancellation token. + */ + provideFileSearchResults(pattern: string, options: FileSearchProviderOptionsNew, token: CancellationToken): ProviderResult; + } + + export namespace workspace { + /** + * + * Register a search provider. + * + * Only one provider can be registered per scheme. + * + * @param scheme The provider will be invoked for workspace folders that have this file scheme. + * @param provider The provider. + * @return A {@link Disposable} that unregisters this provider when being disposed. + */ + export function registerFileSearchProviderNew(scheme: string, provider: FileSearchProviderNew): Disposable; + } +} diff --git a/src/vscode-dts/vscode.proposed.findFiles2New.d.ts b/src/vscode-dts/vscode.proposed.findFiles2New.d.ts new file mode 100644 index 00000000000..cb64dce6166 --- /dev/null +++ b/src/vscode-dts/vscode.proposed.findFiles2New.d.ts @@ -0,0 +1,83 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + export interface FindFiles2OptionsNew { + /** + * A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern + * will be matched against the file paths of resulting matches relative to their workspace. + */ + exclude?: GlobPattern; + + /** + * Which settings to follow when searching for files. Defaults to {@link ExcludeSettingOptions.searchAndFilesExclude}. + */ + useExcludeSettings?: ExcludeSettingOptions; + + /** + * The maximum number of results to search for + */ + maxResults?: number; + + /** + * Which file locations we should look for ignore (.gitignore or .ignore) files to respect. + * + * When any of these fields are `undefined`, we will: + * - assume the value if possible (e.g. if only one is valid) + * or + * - follow settings using the value for the corresponding `search.use*IgnoreFiles` settting. + * + * Will log an error if an invalid combination is set. + */ + useIgnoreFiles?: { + /** + * Use ignore files at the current workspace root. + * May default to `search.useIgnoreFiles` setting if not set. + */ + local?: boolean; + /** + * Use ignore files at the parent directory. When set to `true`, {@link FindFiles2OptionsNew.useIgnoreFiles.local} must also be `true`. + * May default to `search.useParentIgnoreFiles` setting if not set. + */ + parent?: boolean; + /** + * Use global ignore files. When set to `true`, {@link FindFiles2OptionsNew.useIgnoreFiles.local} must also be `true`. + * May default to `search.useGlobalIgnoreFiles` setting if not set. + */ + global?: boolean; + }; + + /** + * Whether symlinks should be followed while searching. + * Defaults to the value for `search.followSymlinks` in settings. + * For more info, see the setting description for `search.followSymlinks`. + */ + followSymlinks?: boolean; + } + + /** + * Represents a session of a currently logged in user. + */ + export namespace workspace { + /** + * WARNING: VERY EXPERIMENTAL. + * + * Find files across all {@link workspace.workspaceFolders workspace folders} in the workspace. + * + * @example + * findFiles('**​/*.js', {exclude: '**​/out/**', useIgnoreFiles: true, maxResults: 10}) + * + * @param filePattern A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern + * will be matched against the file paths of resulting matches relative to their workspace. Use a {@link RelativePattern relative pattern} + * to restrict the search results to a {@link WorkspaceFolder workspace folder}. + * @param options A set of {@link FindFiles2Options FindFiles2Options} that defines where and how to search (e.g. exclude settings). + * @param token A token that can be used to signal cancellation to the underlying search engine. + * @returns A thenable that resolves to an array of resource identifiers. Will return no results if no + * {@link workspace.workspaceFolders workspace folders} are opened. + */ + export function findFiles2New(filePattern: GlobPattern[], options?: FindFiles2OptionsNew, token?: CancellationToken): Thenable; + } +} diff --git a/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts b/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts new file mode 100644 index 00000000000..5766d782527 --- /dev/null +++ b/src/vscode-dts/vscode.proposed.findTextInFilesNew.d.ts @@ -0,0 +1,146 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + // https://github.com/microsoft/vscode/issues/59924 + + /** + * Options that can be set on a findTextInFiles search. + */ + export interface FindTextInFilesOptionsNew { + /** + * A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern + * will be matched against the file paths of resulting matches relative to their workspace. + */ + exclude?: GlobPattern; + + /** + * Which settings to follow when searching for files. Defaults to {@link ExcludeSettingOptions.searchAndFilesExclude}. + */ + useExcludeSettings?: ExcludeSettingOptions; + + /** + * The maximum number of results to search for + */ + maxResults?: number; + + + /** + * Which file locations we should look for ignore (.gitignore or .ignore) files to respect. + * + * When any of these fields are `undefined`, we will: + * - assume the value if possible (e.g. if only one is valid) + * or + * - follow settings using the value for the corresponding `search.use*IgnoreFiles` settting. + * + * Will log an error if an invalid combination is set. + */ + useIgnoreFiles?: { + /** + * Use ignore files at the current workspace root. + * May default to `search.useIgnoreFiles` setting if not set. + */ + local?: boolean; + /** + * Use ignore files at the parent directory. When set to `true`, {@link FindTextInFilesOptionsNew.useIgnoreFiles.local} must be `true`. + * May default to `search.useParentIgnoreFiles` setting if not set. + */ + parent?: boolean; + /** + * Use global ignore files. When set to `true`, {@link FindTextInFilesOptionsNew.useIgnoreFiles.local} must also be `true`. + * May default to `search.useGlobalIgnoreFiles` setting if not set. + */ + global?: boolean; + }; + + /** + * Whether symlinks should be followed while searching. + * Defaults to the value for `search.followSymlinks` in settings. + * For more info, see the setting description for `search.followSymlinks`. + */ + followSymlinks?: boolean; + + /** + * A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern + * will be matched against the file paths of files relative to their workspace. Use a {@link RelativePattern relative pattern} + * to restrict the search results to a {@link WorkspaceFolder workspace folder}. + */ + include?: GlobPattern; + + /** + * Interpret files using this encoding. + * See the vscode setting `"files.encoding"` + */ + encoding?: string; + + /** + * Options to specify the size of the result text preview. + */ + previewOptions?: { + /** + * The maximum number of lines in the preview. + * Only search providers that support multiline search will ever return more than one line in the match. + */ + matchLines?: number; + + /** + * The maximum number of characters included per line. + */ + charsPerLine?: number; + }; + + /** + * Number of lines of context to include before and after each match. + */ + surroundingContext?: number; + } + + export interface FindTextInFilesResponse { + /** + * The results of the text search, in batches. To get completion information, wait on the `complete` property. + */ + results: AsyncIterable; + /** + * The text search completion information. This resolves on completion. + */ + complete: Thenable; + } + + /* + * Options for following search.exclude and files.exclude settings. + */ + export enum ExcludeSettingOptions { + /* + * Don't use any exclude settings. + */ + none = 1, + /* + * Use: + * - files.exclude setting + */ + filesExclude = 2, + /* + * Use: + * - files.exclude setting + * - search.exclude setting + */ + searchAndFilesExclude = 3 + } + + export namespace workspace { + /** + * WARNING: VERY EXPERIMENTAL. + * + * Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace. + * @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words. + * @param options An optional set of query options. Include and exclude patterns, maxResults, etc. + * @param callback A callback, called for each result + * @param token A token that can be used to signal cancellation to the underlying search engine. + * @return A thenable that resolves when the search is complete. + */ + export function findTextInFilesNew(query: TextSearchQueryNew, options?: FindTextInFilesOptionsNew, token?: CancellationToken): FindTextInFilesResponse; + } +} diff --git a/src/vscode-dts/vscode.proposed.textSearchCompleteNew.d.ts b/src/vscode-dts/vscode.proposed.textSearchCompleteNew.d.ts new file mode 100644 index 00000000000..8281931c815 --- /dev/null +++ b/src/vscode-dts/vscode.proposed.textSearchCompleteNew.d.ts @@ -0,0 +1,46 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + export interface TextSearchCompleteNew { + /** + * Additional information regarding the state of the completed search. + * + * Messages with "Information" style support links in markdown syntax: + * - Click to [run a command](command:workbench.action.OpenQuickPick) + * - Click to [open a website](https://aka.ms) + * + * Commands may optionally return { triggerSearch: true } to signal to the editor that the original search should run be again. + */ + message?: TextSearchCompleteMessageNew[]; + } + + /** + * A message regarding a completed search. + */ + export interface TextSearchCompleteMessageNew { + /** + * Markdown text of the message. + */ + text: string; + /** + * Whether the source of the message is trusted, command links are disabled for untrusted message sources. + * Messaged are untrusted by default. + */ + trusted?: boolean; + /** + * The message type, this affects how the message will be rendered. + */ + type: TextSearchCompleteMessageTypeNew; + } + + /** + * Represents the severity of a TextSearchComplete message. + */ + export enum TextSearchCompleteMessageTypeNew { + Information = 1, + Warning = 2, + } +} diff --git a/src/vscode-dts/vscode.proposed.textSearchProviderNew.d.ts b/src/vscode-dts/vscode.proposed.textSearchProviderNew.d.ts new file mode 100644 index 00000000000..13a72372f0b --- /dev/null +++ b/src/vscode-dts/vscode.proposed.textSearchProviderNew.d.ts @@ -0,0 +1,232 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + // https://github.com/microsoft/vscode/issues/59921 + + /** + * The parameters of a query for text search. + */ + export interface TextSearchQueryNew { + /** + * The text pattern to search for. + */ + pattern: string; + + /** + * Whether or not `pattern` should match multiple lines of text. + */ + isMultiline?: boolean; + + /** + * Whether or not `pattern` should be interpreted as a regular expression. + */ + isRegExp?: boolean; + + /** + * Whether or not the search should be case-sensitive. + */ + isCaseSensitive?: boolean; + + /** + * Whether or not to search for whole word matches only. + */ + isWordMatch?: boolean; + } + + /** + * Options that apply to text search. + */ + export interface TextSearchProviderOptionsNew { + + folderOptions: { + /** + * The root folder to search within. + */ + folder: Uri; + + /** + * Files that match an `includes` glob pattern should be included in the search. + */ + includes: string[]; + + /** + * Files that match an `excludes` glob pattern should be excluded from the search. + */ + excludes: GlobPattern[]; + + /** + * Whether symlinks should be followed while searching. + * For more info, see the setting description for `search.followSymlinks`. + */ + followSymlinks: boolean; + + /** + * Which file locations we should look for ignore (.gitignore or .ignore) files to respect. + */ + useIgnoreFiles: { + /** + * Use ignore files at the current workspace root. + */ + local: boolean; + /** + * Use ignore files at the parent directory. If set, {@link TextSearchProviderOptionsNew.useIgnoreFiles.local} should also be `true`. + */ + parent: boolean; + /** + * Use global ignore files. If set, {@link TextSearchProviderOptionsNew.useIgnoreFiles.local} should also be `true`. + */ + global: boolean; + }; + }[]; + + /** + * The maximum number of results to be returned. + */ + maxResults: number; + + /** + * Options to specify the size of the result text preview. + */ + previewOptions: { + /** + * The maximum number of lines in the preview. + * Only search providers that support multiline search will ever return more than one line in the match. + */ + matchLines: number; + + /** + * The maximum number of characters included per line. + */ + charsPerLine: number; + }; + + /** + * Exclude files larger than `maxFileSize` in bytes. + */ + maxFileSize: number; + + /** + * Interpret files using this encoding. + * See the vscode setting `"files.encoding"` + */ + encoding: string; + + /** + * Number of lines of context to include before and after each match. + */ + surroundingContext: number; + } + + /** + * Information collected when text search is complete. + */ + export interface TextSearchCompleteNew { + /** + * Whether the search hit the limit on the maximum number of search results. + * `maxResults` on {@linkcode TextSearchProviderOptionsNew} specifies the max number of results. + * - If exactly that number of matches exist, this should be false. + * - If `maxResults` matches are returned and more exist, this should be true. + * - If search hits an internal limit which is less than `maxResults`, this should be true. + */ + limitHit?: boolean; + } + + /** + * The main match information for a {@link TextSearchResultNew}. + */ + export class TextSearchMatchNew { + /** + * @param uri The uri for the matching document. + * @param ranges The ranges associated with this match. + * @param previewText The text that is used to preview the match. The highlighted range in `previewText` is specified in `ranges`. + */ + constructor(uri: Uri, ranges: { sourceRange: Range; previewRange: Range }[], previewText: string); + + /** + * The uri for the matching document. + */ + uri: Uri; + + /** + * The ranges associated with this match. + */ + ranges: { + /** + * The range of the match within the document, or multiple ranges for multiple matches. + */ + sourceRange: Range; + /** + * The Range within `previewText` corresponding to the text of the match. + */ + previewRange: Range; + }[]; + + previewText: string; + } + + /** + * The potential context information for a {@link TextSearchResultNew}. + */ + export class TextSearchContextNew { + /** + * @param uri The uri for the matching document. + * @param text The line of context text. + * @param lineNumber The line number of this line of context. + */ + constructor(uri: Uri, text: string, lineNumber: number); + + /** + * The uri for the matching document. + */ + uri: Uri; + + /** + * One line of text. + * previewOptions.charsPerLine applies to this + */ + text: string; + + /** + * The line number of this line of context. + */ + lineNumber: number; + } + + /** + * A result payload for a text search, pertaining to matches within a single file. + */ + export type TextSearchResultNew = TextSearchMatchNew | TextSearchContextNew; + + /** + * A TextSearchProvider provides search results for text results inside files in the workspace. + */ + export interface TextSearchProviderNew { + /** + * WARNING: VERY EXPERIMENTAL. + * + * Provide results that match the given text pattern. + * @param query The parameters for this query. + * @param options A set of options to consider while searching. + * @param progress A progress callback that must be invoked for all results. + * @param token A cancellation token. + */ + provideTextSearchResults(query: TextSearchQueryNew, options: TextSearchProviderOptionsNew, progress: Progress, token: CancellationToken): ProviderResult; + } + + export namespace workspace { + /** + * Register a text search provider. + * + * Only one provider can be registered per scheme. + * + * @param scheme The provider will be invoked for workspace folders that have this file scheme. + * @param provider The provider. + * @return A {@link Disposable} that unregisters this provider when being disposed. + */ + export function registerTextSearchProviderNew(scheme: string, provider: TextSearchProviderNew): Disposable; + } +}