mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 11:38:36 -05:00
Merge from vscode 2b0b9136329c181a9e381463a1f7dc3a2d105a34 (#4880)
This commit is contained in:
@@ -10,12 +10,14 @@ import { NodeStringDecoder, StringDecoder } from 'string_decoder';
|
||||
import { createRegExp, startsWith, startsWithUTF8BOM, stripUTF8BOM, escapeRegExpCharacters, endsWith } from 'vs/base/common/strings';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IExtendedExtensionSearchOptions, SearchError, SearchErrorCode, serializeSearchError } from 'vs/workbench/services/search/common/search';
|
||||
import * as vscode from 'vscode';
|
||||
import { rgPath } from 'vscode-ripgrep';
|
||||
import { anchorGlob, createTextSearchResult, IOutputChannel, Maybe, Range } from './ripgrepSearchUtils';
|
||||
import { anchorGlob, createTextSearchResult, IOutputChannel, Maybe } from './ripgrepSearchUtils';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
import { splitGlobAware } from 'vs/base/common/glob';
|
||||
import { groupBy } from 'vs/base/common/collections';
|
||||
import { TextSearchQuery, TextSearchOptions, TextSearchResult, TextSearchComplete, TextSearchPreviewOptions, TextSearchContext, TextSearchMatch, Range } from 'vs/workbench/services/search/common/searchExtTypes';
|
||||
import { Progress } from 'vs/platform/progress/common/progress';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
// If vscode-ripgrep is in an .asar file, then the binary is unpacked.
|
||||
const rgDiskPath = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked');
|
||||
@@ -24,7 +26,7 @@ export class RipgrepTextSearchEngine {
|
||||
|
||||
constructor(private outputChannel: IOutputChannel) { }
|
||||
|
||||
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Promise<vscode.TextSearchComplete> {
|
||||
provideTextSearchResults(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Promise<TextSearchComplete> {
|
||||
this.outputChannel.appendLine(`provideTextSearchResults ${query.pattern}, ${JSON.stringify({
|
||||
...options,
|
||||
...{
|
||||
@@ -53,7 +55,7 @@ export class RipgrepTextSearchEngine {
|
||||
|
||||
let gotResult = false;
|
||||
const ripgrepParser = new RipgrepParser(options.maxResults, cwd, options.previewOptions);
|
||||
ripgrepParser.on('result', (match: vscode.TextSearchResult) => {
|
||||
ripgrepParser.on('result', (match: TextSearchResult) => {
|
||||
gotResult = true;
|
||||
progress.report(match);
|
||||
});
|
||||
@@ -155,7 +157,7 @@ export class RipgrepParser extends EventEmitter {
|
||||
|
||||
private numResults = 0;
|
||||
|
||||
constructor(private maxResults: number, private rootFolder: string, private previewOptions?: vscode.TextSearchPreviewOptions) {
|
||||
constructor(private maxResults: number, private rootFolder: string, private previewOptions?: TextSearchPreviewOptions) {
|
||||
super();
|
||||
this.stringDecoder = new StringDecoder();
|
||||
}
|
||||
@@ -169,7 +171,7 @@ export class RipgrepParser extends EventEmitter {
|
||||
}
|
||||
|
||||
|
||||
on(event: 'result', listener: (result: vscode.TextSearchResult) => void): this;
|
||||
on(event: 'result', listener: (result: TextSearchResult) => void): this;
|
||||
on(event: 'hitLimit', listener: () => void): this;
|
||||
on(event: string, listener: (...args: any[]) => void): this {
|
||||
super.on(event, listener);
|
||||
@@ -240,7 +242,7 @@ export class RipgrepParser extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
private createTextSearchMatch(data: IRgMatch, uri: vscode.Uri): vscode.TextSearchMatch {
|
||||
private createTextSearchMatch(data: IRgMatch, uri: URI): TextSearchMatch {
|
||||
const lineNumber = data.line_number - 1;
|
||||
let isBOMStripped = false;
|
||||
let fullText = bytesOrTextToString(data.lines);
|
||||
@@ -290,7 +292,7 @@ export class RipgrepParser extends EventEmitter {
|
||||
return createTextSearchResult(uri, fullText, <Range[]>ranges, this.previewOptions);
|
||||
}
|
||||
|
||||
private createTextSearchContext(data: IRgMatch, uri: URI): vscode.TextSearchContext[] {
|
||||
private createTextSearchContext(data: IRgMatch, uri: URI): TextSearchContext[] {
|
||||
const text = bytesOrTextToString(data.lines);
|
||||
const startLine = data.line_number;
|
||||
return text
|
||||
@@ -305,7 +307,7 @@ export class RipgrepParser extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
private onResult(match: vscode.TextSearchResult): void {
|
||||
private onResult(match: TextSearchResult): void {
|
||||
this.emit('result', match);
|
||||
}
|
||||
}
|
||||
@@ -333,7 +335,7 @@ function getNumLinesAndLastNewlineLength(text: string): { numLines: number, last
|
||||
return { numLines, lastLineLength };
|
||||
}
|
||||
|
||||
function getRgArgs(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions): string[] {
|
||||
function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[] {
|
||||
const args = ['--hidden'];
|
||||
args.push(query.isCaseSensitive ? '--case-sensitive' : '--ignore-case');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user