Skip to content

Commit 62ec995

Browse files
committed
Ripgrep search
1 parent 066699c commit 62ec995

File tree

8 files changed

+311
-75
lines changed

8 files changed

+311
-75
lines changed

.vscode/launch.json

+10
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@
6363
"${workspaceRoot}/out/**/*.js"
6464
]
6565
},
66+
{
67+
"type": "node",
68+
"request": "attach",
69+
"name": "Attach to Search process",
70+
"port": 7890,
71+
"sourceMaps": true,
72+
"outFiles": [
73+
"${workspaceRoot}/out/**/*.js"
74+
]
75+
},
6676
{
6777
"type": "node",
6878
"request": "attach",

npm-shrinkwrap.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"semver": "4.3.6",
3636
"v8-profiler": "jrieken/v8-profiler#vscode",
3737
"vscode-debugprotocol": "1.17.0",
38-
"vscode-ripgrep": "0.0.8",
38+
"vscode-ripgrep": "0.0.10",
3939
"vscode-textmate": "^3.1.1",
4040
"winreg": "1.2.0",
4141
"xterm": "Tyriar/xterm.js#vscode-release/1.11",

src/typings/vscode-ripgrep.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'vscode-ripgrep' {
2+
export const rgPath: string;
3+
}

src/vs/workbench/parts/search/browser/searchViewlet.ts

+4-47
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { Viewlet } from 'vs/workbench/browser/viewlet';
3535
import { Match, FileMatch, SearchModel, FileMatchOrMatch, IChangeEvent, ISearchWorkbenchService } from 'vs/workbench/parts/search/common/searchModel';
3636
import { QueryBuilder } from 'vs/workbench/parts/search/common/searchQuery';
3737
import { MessageType, InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
38-
import { getExcludes, ISearchProgressItem, ISearchComplete, ISearchQuery, IQueryOptions, ISearchConfiguration } from 'vs/platform/search/common/search';
38+
import { getExcludes, ISearchComplete, ISearchQuery, IQueryOptions, ISearchConfiguration } from 'vs/platform/search/common/search';
3939
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
4040
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
4141
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -988,10 +988,7 @@ export class SearchViewlet extends Viewlet {
988988
private onQueryTriggered(query: ISearchQuery, excludePattern: string, includePattern: string): void {
989989
this.viewModel.cancelSearch();
990990

991-
// Progress total is 100.0% for more progress bar granularity
992-
let progressTotal = 1000;
993-
let progressRunner = this.progressService.show(progressTotal);
994-
let progressWorked = 0;
991+
let progressRunner = this.progressService.show(/*infinite=*/true);
995992

996993
this.loading = true;
997994
this.searchWidget.searchInput.clearMessage();
@@ -1015,14 +1012,7 @@ export class SearchViewlet extends Viewlet {
10151012
let isDone = false;
10161013
let onComplete = (completed?: ISearchComplete) => {
10171014
isDone = true;
1018-
1019-
// Complete up to 100% as needed
1020-
if (completed) {
1021-
progressRunner.worked(progressTotal - progressWorked);
1022-
setTimeout(() => progressRunner.done(), 200);
1023-
} else {
1024-
progressRunner.done();
1025-
}
1015+
progressRunner.done();
10261016

10271017
this.onSearchResultsChanged().then(() => autoExpand(true));
10281018
this.viewModel.replaceString = this.searchWidget.getReplaceValue();
@@ -1126,18 +1116,7 @@ export class SearchViewlet extends Viewlet {
11261116
}
11271117
};
11281118

1129-
let total: number = 0;
1130-
let worked: number = 0;
11311119
let visibleMatches = 0;
1132-
let onProgress = (p: ISearchProgressItem) => {
1133-
// Progress
1134-
if (p.total) {
1135-
total = p.total;
1136-
}
1137-
if (p.worked) {
1138-
worked = p.worked;
1139-
}
1140-
};
11411120

11421121
// Handle UI updates in an interval to show frequent progress and results
11431122
let uiRefreshHandle = setInterval(() => {
@@ -1146,28 +1125,6 @@ export class SearchViewlet extends Viewlet {
11461125
return;
11471126
}
11481127

1149-
// Progress bar update
1150-
let fakeProgress = true;
1151-
if (total > 0 && worked > 0) {
1152-
let ratio = Math.round((worked / total) * progressTotal);
1153-
if (ratio > progressWorked) { // never show less progress than what we have already
1154-
progressRunner.worked(ratio - progressWorked);
1155-
progressWorked = ratio;
1156-
fakeProgress = false;
1157-
}
1158-
}
1159-
1160-
// Fake progress up to 90%, or when actual progress beats it
1161-
const fakeMax = 900;
1162-
const fakeMultiplier = 12;
1163-
if (fakeProgress && progressWorked < fakeMax) {
1164-
// Linearly decrease the rate of fake progress.
1165-
// 1 is the smallest allowed amount of progress.
1166-
const fakeAmt = Math.round((fakeMax - progressWorked) / fakeMax * fakeMultiplier) || 1;
1167-
progressWorked += fakeAmt;
1168-
progressRunner.worked(fakeAmt);
1169-
}
1170-
11711128
// Search result tree update
11721129
const fileCount = this.viewModel.searchResult.fileCount();
11731130
if (visibleMatches !== fileCount) {
@@ -1188,7 +1145,7 @@ export class SearchViewlet extends Viewlet {
11881145

11891146
this.searchWidget.setReplaceAllActionState(false);
11901147
// this.replaceService.disposeAllReplacePreviews();
1191-
this.viewModel.search(query).done(onComplete, onError, onProgress);
1148+
this.viewModel.search(query).done(onComplete, onError);
11921149
}
11931150

11941151
private updateSearchResultCount(): void {

src/vs/workbench/services/search/node/rawSearchService.ts

+4-23
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ import objects = require('vs/base/common/objects');
1717
import scorer = require('vs/base/common/scorer');
1818
import strings = require('vs/base/common/strings');
1919
import { PPromise, TPromise } from 'vs/base/common/winjs.base';
20-
import { MAX_FILE_SIZE } from 'vs/platform/files/common/files';
21-
import { FileWalker, Engine as FileSearchEngine } from 'vs/workbench/services/search/node/fileSearch';
22-
import { Engine as TextSearchEngine } from 'vs/workbench/services/search/node/textSearch';
23-
import { TextSearchWorkerProvider } from 'vs/workbench/services/search/node/textSearchWorkerProvider';
20+
import { Engine as FileSearchEngine } from 'vs/workbench/services/search/node/fileSearch';
21+
import { RipgrepEngine } from 'vs/workbench/services/search/node/ripgrepTextSearch';
2422
import { IRawSearchService, IRawSearch, IRawFileMatch, ISerializedFileMatch, ISerializedSearchProgressItem, ISerializedSearchComplete, ISearchEngine } from './search';
2523
import { ICachedSearchStats, IProgress } from 'vs/platform/search/common/search';
2624

@@ -32,29 +30,12 @@ export class SearchService implements IRawSearchService {
3230

3331
private caches: { [cacheKey: string]: Cache; } = Object.create(null);
3432

35-
private textSearchWorkerProvider: TextSearchWorkerProvider;
36-
3733
public fileSearch(config: IRawSearch): PPromise<ISerializedSearchComplete, ISerializedSearchProgressItem> {
3834
return this.doFileSearch(FileSearchEngine, config, SearchService.BATCH_SIZE);
3935
}
4036

4137
public textSearch(config: IRawSearch): PPromise<ISerializedSearchComplete, ISerializedSearchProgressItem> {
42-
if (!this.textSearchWorkerProvider) {
43-
this.textSearchWorkerProvider = new TextSearchWorkerProvider();
44-
}
45-
46-
let engine = new TextSearchEngine(
47-
config,
48-
new FileWalker({
49-
rootFolders: config.rootFolders,
50-
extraFiles: config.extraFiles,
51-
includePattern: config.includePattern,
52-
excludePattern: config.excludePattern,
53-
filePattern: config.filePattern,
54-
maxFilesize: MAX_FILE_SIZE
55-
}),
56-
this.textSearchWorkerProvider);
57-
38+
let engine = new RipgrepEngine(config);
5839
return this.doTextSearch(engine, SearchService.BATCH_SIZE);
5940
}
6041

@@ -279,7 +260,7 @@ export class SearchService implements IRawSearchService {
279260
});
280261
}
281262

282-
private doTextSearch(engine: TextSearchEngine, batchSize: number): PPromise<ISerializedSearchComplete, IRawProgressItem<ISerializedFileMatch>> {
263+
private doTextSearch(engine: RipgrepEngine, batchSize: number): PPromise<ISerializedSearchComplete, IRawProgressItem<ISerializedFileMatch>> {
283264
return new PPromise<ISerializedSearchComplete, IRawProgressItem<ISerializedFileMatch>>((c, e, p) => {
284265
// Use BatchedCollector to get new results to the frontend every 2s at least, until 50 results have been returned
285266
const collector = new BatchedCollector<ISerializedFileMatch>(batchSize, p);

0 commit comments

Comments
 (0)