diff --git a/packages/search-in-workspace/package.json b/packages/search-in-workspace/package.json index 755c99bddd040..d2d5d0526ce48 100644 --- a/packages/search-in-workspace/package.json +++ b/packages/search-in-workspace/package.json @@ -5,6 +5,10 @@ "dependencies": { "@theia/core": "^0.3.14", "@theia/editor": "^0.3.14", + "@theia/workspace": "^0.3.14", + "@theia/filesystem": "^0.3.14", + "@theia/navigator": "^0.3.14", + "@theia/process": "^0.3.14", "vscode-ripgrep": "^1.0.1" }, "publishConfig": { diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-service.ts b/packages/search-in-workspace/src/browser/search-in-workspace-service.ts index 1b77fc7106e77..510787157c3a7 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-service.ts +++ b/packages/search-in-workspace/src/browser/search-in-workspace-service.ts @@ -17,7 +17,6 @@ import { injectable, inject, postConstruct } from 'inversify'; import { SearchInWorkspaceServer, SearchInWorkspaceClient, SearchInWorkspaceResult, SearchInWorkspaceOptions } from '../common/search-in-workspace-interface'; import { WorkspaceService } from '@theia/workspace/lib/browser'; -import URI from '@theia/core/lib/common/uri'; import { ILogger } from '@theia/core'; /** @@ -112,8 +111,7 @@ export class SearchInWorkspaceService implements SearchInWorkspaceClient { throw new Error('Search failed: no workspace root.'); } - const rootUri = new URI(root.uri); - const searchId = await this.searchServer.search(what, rootUri.path.toString(), opts); + const searchId = await this.searchServer.search(what, root.uri, opts); this.pendingSearches.set(searchId, callbacks); this.lastKnownSearchId = searchId; diff --git a/packages/search-in-workspace/src/common/search-in-workspace-interface.ts b/packages/search-in-workspace/src/common/search-in-workspace-interface.ts index aa4ad903b8dfd..a2b219a6a1d8c 100644 --- a/packages/search-in-workspace/src/common/search-in-workspace-interface.ts +++ b/packages/search-in-workspace/src/common/search-in-workspace-interface.ts @@ -116,7 +116,7 @@ export interface SearchInWorkspaceServer extends JsonRpcServer; + search(what: string, rootUri: string, opts?: SearchInWorkspaceOptions): Promise; /** * Cancel an ongoing search. diff --git a/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.slow-spec.ts b/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.slow-spec.ts index b9648492b289e..62b2d70c14608 100644 --- a/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.slow-spec.ts +++ b/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.slow-spec.ts @@ -25,6 +25,7 @@ import { ILogger, isWindows } from '@theia/core'; import { MockLogger } from '@theia/core/lib/common/test/mock-logger'; import { RawProcessFactory, RawProcessOptions, RawProcess, ProcessManager } from '@theia/process/lib/node'; import * as path from 'path'; +import { FileUri } from '@theia/core/lib/node/file-uri'; // Allow creating temporary files, but remove them when we are done. const track = temp.track(); @@ -169,7 +170,7 @@ function compareSearchResults(expected: SearchInWorkspaceResult[], actual: Searc if (lines) { const line = lines[e.line - 1]; e.lineText = line; - e.file = path.join(rootDir, e.file); + e.file = FileUri.fsPath(path.join(rootDir, e.file)); expect(a).deep.eq(e); } else { diff --git a/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.ts b/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.ts index 36776703bf348..3be962924bdc7 100644 --- a/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.ts +++ b/packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.ts @@ -19,6 +19,7 @@ import { ILogger } from '@theia/core'; import { inject, injectable } from 'inversify'; import { RawProcess, RawProcessFactory, RawProcessOptions } from '@theia/process/lib/node'; import { rgPath } from 'vscode-ripgrep'; +import { FileUri } from '@theia/core/lib/node/file-uri'; @injectable() export class RipgrepSearchInWorkspaceServer implements SearchInWorkspaceServer { @@ -78,7 +79,7 @@ export class RipgrepSearchInWorkspaceServer implements SearchInWorkspaceServer { } // Search for the string WHAT in directory ROOT. Return the assigned search id. - search(what: string, root: string, opts?: SearchInWorkspaceOptions): Promise { + search(what: string, rootUri: string, opts?: SearchInWorkspaceOptions): Promise { // Start the rg process. Use --vimgrep to get one result per // line, --color=always to get color control characters that // we'll use to parse the lines. @@ -101,7 +102,7 @@ export class RipgrepSearchInWorkspaceServer implements SearchInWorkspaceServer { } const processOptions: RawProcessOptions = { command: rgPath, - args: [...args, what, ...globs, root] + args: [...args, what, ...globs, FileUri.fsPath(rootUri)] }; const process: RawProcess = this.rawProcessFactory(processOptions); this.ongoingSearches.set(searchId, process);