Skip to content

Commit

Permalink
Use filesystem specific path for search path
Browse files Browse the repository at this point in the history
Signed-off-by: William Gonzalez <William.Gonzalez@arm.com>
  • Loading branch information
William Gonzalez authored and William Gonzalez committed Sep 13, 2018
1 parent edea768 commit 442345d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/search-in-workspace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export interface SearchInWorkspaceServer extends JsonRpcServer<SearchInWorkspace
/**
* Start a search for WHAT in directory ROOT. Return a unique search id.
*/
search(what: string, root: string, opts?: SearchInWorkspaceOptions): Promise<number>;
search(what: string, rootUri: string, opts?: SearchInWorkspaceOptions): Promise<number>;

/**
* Cancel an ongoing search.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<number> {
search(what: string, rootUri: string, opts?: SearchInWorkspaceOptions): Promise<number> {
// 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.
Expand All @@ -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);
Expand Down

0 comments on commit 442345d

Please sign in to comment.