mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
Fix #57951 - remove $cancelSearch
This commit is contained in:
@@ -470,10 +470,9 @@ export interface ExtHostUrlsShape {
|
||||
}
|
||||
|
||||
export interface MainThreadWorkspaceShape extends IDisposable {
|
||||
$startFileSearch(includePattern: string, includeFolder: string, excludePatternOrDisregardExcludes: string | false, maxResults: number, requestId: number): Thenable<UriComponents[]>;
|
||||
$startTextSearch(query: IPatternInfo, options: IQueryOptions, requestId: number): Thenable<void>;
|
||||
$checkExists(includes: string[], requestId: number): Thenable<boolean>;
|
||||
$cancelSearch(requestId: number): Thenable<boolean>;
|
||||
$startFileSearch(includePattern: string, includeFolder: string, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Thenable<UriComponents[]>;
|
||||
$startTextSearch(query: IPatternInfo, options: IQueryOptions, requestId: number, token: CancellationToken): Thenable<void>;
|
||||
$checkExists(includes: string[], token: CancellationToken): Thenable<boolean>;
|
||||
$saveAll(includeUntitled?: boolean): Thenable<boolean>;
|
||||
$updateWorkspaceFolders(extensionName: string, index: number, deleteCount: number, workspaceFoldersToAdd: { uri: UriComponents, name?: string }[]): Thenable<void>;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ export class ExtHostSearch implements ExtHostSearchShape {
|
||||
});
|
||||
} else {
|
||||
const indexProvider = this._fileIndexProvider.get(handle);
|
||||
return this._fileIndexSearchManager.fileSearch(query, indexProvider, batch => {
|
||||
const searchP = this._fileIndexSearchManager.fileSearch(query, indexProvider, batch => {
|
||||
this._proxy.$handleFileMatch(handle, session, batch.map(p => p.resource));
|
||||
}).then(null, err => {
|
||||
if (!isPromiseCanceledError(err)) {
|
||||
@@ -102,6 +102,10 @@ export class ExtHostSearch implements ExtHostSearchShape {
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
token.onCancellationRequested(() => searchP.cancel());
|
||||
|
||||
return searchP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import { Range } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import * as vscode from 'vscode';
|
||||
import { ExtHostWorkspaceShape, IMainContext, IWorkspaceData, MainContext, MainThreadMessageServiceShape, MainThreadWorkspaceShape } from './extHost.protocol';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
function isFolderEqual(folderA: URI, folderB: URI): boolean {
|
||||
return isEqual(folderA, folderB, !isLinux);
|
||||
@@ -345,11 +346,9 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
|
||||
|
||||
// --- search ---
|
||||
|
||||
findFiles(include: vscode.GlobPattern, exclude: vscode.GlobPattern, maxResults: number, extensionId: string, token?: vscode.CancellationToken): Thenable<vscode.Uri[]> {
|
||||
findFiles(include: vscode.GlobPattern, exclude: vscode.GlobPattern, maxResults: number, extensionId: string, token: vscode.CancellationToken = CancellationToken.None): Thenable<vscode.Uri[]> {
|
||||
this._logService.trace(`extHostWorkspace#findFiles: fileSearch, extension: ${extensionId}, entryPoint: findFiles`);
|
||||
|
||||
const requestId = this._requestIdProvider.getNext();
|
||||
|
||||
let includePattern: string;
|
||||
let includeFolder: string;
|
||||
if (include) {
|
||||
@@ -376,14 +375,11 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
|
||||
return TPromise.wrap([]);
|
||||
}
|
||||
|
||||
const result = this._proxy.$startFileSearch(includePattern, includeFolder, excludePatternOrDisregardExcludes, maxResults, requestId);
|
||||
if (token) {
|
||||
token.onCancellationRequested(() => this._proxy.$cancelSearch(requestId));
|
||||
}
|
||||
return result.then(data => Array.isArray(data) ? data.map(URI.revive) : []);
|
||||
return this._proxy.$startFileSearch(includePattern, includeFolder, excludePatternOrDisregardExcludes, maxResults, token)
|
||||
.then(data => Array.isArray(data) ? data.map(URI.revive) : []);
|
||||
}
|
||||
|
||||
findTextInFiles(query: vscode.TextSearchQuery, options: vscode.FindTextInFilesOptions, callback: (result: vscode.TextSearchResult) => void, extensionId: string, token?: vscode.CancellationToken) {
|
||||
findTextInFiles(query: vscode.TextSearchQuery, options: vscode.FindTextInFilesOptions, callback: (result: vscode.TextSearchResult) => void, extensionId: string, token: vscode.CancellationToken = CancellationToken.None) {
|
||||
this._logService.trace(`extHostWorkspace#findTextInFiles: textSearch, extension: ${extensionId}, entryPoint: findTextInFiles`);
|
||||
|
||||
if (options.previewOptions && options.previewOptions.totalChars <= options.previewOptions.leadingChars) {
|
||||
@@ -431,18 +427,11 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
|
||||
});
|
||||
};
|
||||
|
||||
if (token) {
|
||||
if (token.isCancellationRequested) {
|
||||
return TPromise.wrap(undefined);
|
||||
} else {
|
||||
token.onCancellationRequested(() => {
|
||||
isCanceled = true;
|
||||
this._proxy.$cancelSearch(requestId);
|
||||
});
|
||||
}
|
||||
if (token.isCancellationRequested) {
|
||||
return TPromise.wrap(undefined);
|
||||
}
|
||||
|
||||
return this._proxy.$startTextSearch(query, queryOptions, requestId).then(
|
||||
return this._proxy.$startTextSearch(query, queryOptions, requestId, token).then(
|
||||
() => {
|
||||
delete this._activeSearchCallbacks[requestId];
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user