Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[search-in-workspace][windows] Fix search in workspace for Windows #2648

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's very good, thanks for spotting it :)

"@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