提交 383d1054 编写于 作者: R Rob Lourens

Send request to search proc ASAP, and send local results ASAP

上级 177700c0
......@@ -552,7 +552,6 @@ export class SearchModel extends Disposable {
this._searchResult.query = this._searchQuery.contentPattern;
this._replacePattern = new ReplacePattern(this._replaceString, this._searchQuery.contentPattern);
const onDone = fromPromise(this.currentRequest);
const onDoneStopwatch = stopwatch(onDone);
const start = Date.now();
......
......@@ -63,23 +63,18 @@ export class SearchService implements ISearchService {
let rawSearchQuery: PPromise<void, ISearchProgressItem>;
return new PPromise<ISearchComplete, ISearchProgressItem>((onComplete, onError, onProgress) => {
const searchP = this.diskSearch.search(query);
// Get local results from dirty/untitled
let localResultsFlushed = false;
let localResults = this.getLocalResults(query);
const localResults = this.getLocalResults(query);
let flushLocalResultsOnce = function () {
if (!localResultsFlushed) {
localResultsFlushed = true;
localResults.values().filter((res) => !!res).forEach(onProgress);
}
};
// Allow caller to register progress callback
process.nextTick(() => localResults.values().filter((res) => !!res).forEach(onProgress));
// Delegate to parent for real file results
rawSearchQuery = this.diskSearch.search(query).then(
rawSearchQuery = searchP.then(
// on Complete
(complete) => {
flushLocalResultsOnce();
onComplete({
limitHit: complete.limitHit,
results: complete.results.filter((match) => !localResults.has(match.resource)), // dont override local results
......@@ -89,13 +84,11 @@ export class SearchService implements ISearchService {
// on Error
(error) => {
flushLocalResultsOnce();
onError(error);
},
// on Progress
(progress) => {
flushLocalResultsOnce();
// Match
if (progress.resource) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册