Rename previewOptions

This commit is contained in:
Rob Lourens
2018-09-24 21:08:11 -07:00
parent 1e058b76ea
commit 3da89c1937
7 changed files with 19 additions and 19 deletions

View File

@@ -22,9 +22,9 @@ export function anchorGlob(glob: string): string {
export function createTextSearchResult(uri: vscode.Uri, fullText: string, range: vscode.Range, previewOptions?: vscode.TextSearchPreviewOptions): vscode.TextSearchResult {
let preview: vscode.TextSearchResultPreview;
if (previewOptions) {
const leadingChars = Math.floor(previewOptions.totalChars / 5);
const leadingChars = Math.floor(previewOptions.charsPerLine / 5);
const previewStart = Math.max(range.start.character - leadingChars, 0);
const previewEnd = previewOptions.totalChars + previewStart;
const previewEnd = previewOptions.charsPerLine + previewStart;
const endOfMatchRangeInPreview = Math.min(previewEnd, range.end.character - previewStart);
preview = {

View File

@@ -514,8 +514,8 @@ suite('workspace-namespace', () => {
const options: vscode.FindTextInFilesOptions = {
include: '*.ts',
previewOptions: {
maxLines: 1,
totalChars: 100
matchLines: 1,
charsPerLine: 100
}
};

View File

@@ -140,8 +140,8 @@ export interface IFileMatch<U extends UriComponents = uri> {
export type IRawFileMatch2 = IFileMatch<UriComponents>;
export interface ITextSearchPreviewOptions {
maxLines: number;
totalChars: number;
matchLines: number;
charsPerLine: number;
}
export interface ISearchRange {
@@ -237,9 +237,9 @@ export class TextSearchResult implements ITextSearchResult {
constructor(fullLine: string, range: ISearchRange, previewOptions?: ITextSearchPreviewOptions) {
this.range = range;
if (previewOptions) {
const leadingChars = Math.floor(previewOptions.totalChars / 5);
const leadingChars = Math.floor(previewOptions.charsPerLine / 5);
const previewStart = Math.max(range.startColumn - leadingChars, 0);
const previewEnd = previewOptions.totalChars + previewStart;
const previewEnd = previewOptions.charsPerLine + previewStart;
const endOfMatchRangeInPreview = Math.min(previewEnd, range.endColumn - previewStart);
this.preview = {

View File

@@ -10,8 +10,8 @@ import { ITextSearchPreviewOptions, OneLineRange, TextSearchResult } from 'vs/pl
suite('TextSearchResult', () => {
const previewOptions1: ITextSearchPreviewOptions = {
maxLines: 1,
totalChars: 100
matchLines: 1,
charsPerLine: 100
};
function assertPreviewRangeText(text: string, result: TextSearchResult): void {
@@ -71,8 +71,8 @@ suite('TextSearchResult', () => {
test('truncating match', () => {
const previewOptions: ITextSearchPreviewOptions = {
maxLines: 1,
totalChars: 1
matchLines: 1,
charsPerLine: 1
};
const range = new OneLineRange(0, 4, 7);

View File

@@ -97,12 +97,12 @@ declare module 'vscode' {
* 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.
*/
maxLines: number;
matchLines: number;
/**
* The maximum number of characters included per line.
*/
totalChars: number;
charsPerLine: number;
}
/**

View File

@@ -396,8 +396,8 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
const previewOptions: vscode.TextSearchPreviewOptions = typeof options.previewOptions === 'undefined' ?
{
maxLines: 100,
totalChars: 10000
matchLines: 100,
charsPerLine: 10000
} :
options.previewOptions;

View File

@@ -1061,7 +1061,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
// Need the full match line to correctly calculate replace text, if this is a search/replace with regex group references ($1, $2, ...).
// 10000 chars is enough to avoid sending huge amounts of text around, if you do a replace with a longer match, it may or may not resolve the group refs correctly.
// https://github.com/Microsoft/vscode/issues/58374
const totalChars = content.isRegExp ? 10000 :
const charsPerLine = content.isRegExp ? 10000 :
250;
const options: IQueryOptions = {
@@ -1072,8 +1072,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
excludePattern,
includePattern,
previewOptions: {
maxLines: 1,
totalChars
matchLines: 1,
charsPerLine
}
};
const folderResources = this.contextService.getWorkspace().folders;