mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
#57186 - implement previewOptions for findTextInFiles
This commit is contained in:
parent
fd76ad9f00
commit
3f7afc6504
|
@ -511,12 +511,22 @@ suite('workspace-namespace', () => {
|
|||
});
|
||||
|
||||
test('findTextInFiles', async () => {
|
||||
const options: vscode.FindTextInFilesOptions = {
|
||||
include: '*.ts',
|
||||
previewOptions: {
|
||||
leadingChars: 2,
|
||||
maxLines: 1,
|
||||
totalChars: 100
|
||||
}
|
||||
};
|
||||
|
||||
const results: vscode.TextSearchResult[] = [];
|
||||
await vscode.workspace.findTextInFiles({ pattern: 'foo' }, { include: '*.ts' }, result => {
|
||||
await vscode.workspace.findTextInFiles({ pattern: 'foo' }, options, result => {
|
||||
results.push(result);
|
||||
});
|
||||
|
||||
assert.equal(results.length, 1);
|
||||
assert.equal(results[0].preview.text, 'n foo(): void {');
|
||||
assert.equal(vscode.workspace.asRelativePath(results[0].uri), '10linefile.ts');
|
||||
});
|
||||
|
||||
|
|
2
src/vs/vscode.proposed.d.ts
vendored
2
src/vs/vscode.proposed.d.ts
vendored
|
@ -260,6 +260,8 @@ declare module 'vscode' {
|
|||
* See the vscode setting `"files.encoding"`
|
||||
*/
|
||||
encoding?: string;
|
||||
|
||||
previewOptions?: TextSearchPreviewOptions;
|
||||
}
|
||||
|
||||
export namespace workspace {
|
||||
|
|
|
@ -398,6 +398,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
|
|||
disregardExcludeSettings: options.exclude === null,
|
||||
fileEncoding: options.encoding,
|
||||
maxResults: options.maxResults,
|
||||
previewOptions: options.previewOptions,
|
||||
|
||||
includePattern: options.include && globPatternToString(options.include),
|
||||
excludePattern: options.exclude && globPatternToString(options.exclude)
|
||||
|
|
|
@ -1086,9 +1086,9 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
|
|||
excludePattern,
|
||||
includePattern,
|
||||
previewOptions: {
|
||||
leadingChars: 5,
|
||||
leadingChars: 20,
|
||||
maxLines: 1,
|
||||
totalChars: this.isWide ? 1000 : 100
|
||||
totalChars: this.isWide ? 250 : 75
|
||||
}
|
||||
};
|
||||
const folderResources = this.contextService.getWorkspace().folders;
|
||||
|
|
Loading…
Reference in a new issue