提交 0b9b3360 编写于 作者: J Johannes Rieken

refine text search api, #41536

上级 c75ebac6
......@@ -83,7 +83,14 @@ declare module 'vscode' {
type: FileType;
}
export interface FindMatch {
export interface TextSearchQuery {
pattern: string;
isRegex?: boolean;
isCaseSensitive?: boolean;
isWordMatch?: boolean;
}
export interface TextSearchResult {
uri: Uri;
range: Range;
preview: { leading: string, matching: string, trailing: string };
......@@ -137,7 +144,8 @@ declare module 'vscode' {
// find files by names
findFiles?(query: string, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
findInFiles?(query: string, isRegex: boolean, progress: Progress<FindMatch>, token: CancellationToken): Thenable<void>;
provideTextSearchResults?(query: TextSearchQuery, include: GlobPattern, exclude: GlobPattern, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
}
export namespace workspace {
......
......@@ -173,7 +173,7 @@ class RemoteFileSystemProvider implements IFileSystemProvider, ISearchResultProv
const promise = query.type === QueryType.File
? this._proxy.$findFiles(this._handle, search.id, query.filePattern)
: this._proxy.$findInFiles(this._handle, search.id, query.contentPattern);
: this._proxy.$provideTextSearchResults(this._handle, search.id, query.contentPattern, undefined, undefined);
promise.then(() => {
this._searches.delete(search.id);
......
......@@ -544,7 +544,7 @@ export interface ExtHostFileSystemShape {
$readdir(handle: number, resource: UriComponents): TPromise<[UriComponents, IStat][]>;
$rmdir(handle: number, resource: UriComponents): TPromise<void>;
$findFiles(handle: number, session: number, query: string): TPromise<void>;
$findInFiles(handle: number, session: number, pattern: IPatternInfo): TPromise<void>;
$provideTextSearchResults(handle: number, session: number, pattern: IPatternInfo, include: string, exclude: string): TPromise<void>;
}
export interface ExtHostExtensionServiceShape {
......
......@@ -87,13 +87,13 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
};
return asWinJsPromise(token => provider.findFiles(query, progress, token));
}
$findInFiles(handle: number, session: number, pattern: IPatternInfo): TPromise<void> {
$provideTextSearchResults(handle: number, session: number, pattern: IPatternInfo, include: string, exclude: string): TPromise<void> {
const provider = this._provider.get(handle);
if (!provider.findInFiles) {
if (!provider.provideTextSearchResults) {
return TPromise.as(undefined);
}
const progress = {
report: (data: vscode.FindMatch) => {
report: (data: vscode.TextSearchResult) => {
this._proxy.$handleFindMatch(handle, session, [data.uri, {
lineNumber: 1 + data.range.start.line,
preview: data.preview.leading + data.preview.matching + data.preview.trailing,
......@@ -101,6 +101,6 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
}]);
}
};
return asWinJsPromise(token => provider.findInFiles(pattern.pattern, pattern.isRegExp, progress, token));
return asWinJsPromise(token => provider.provideTextSearchResults(pattern, include, exclude, progress, token));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册