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

Conversation

gonzalezw
Copy link
Contributor

Changes

  • Fixes getting path to search directory to be file system specific

Fixes Theia issue 2039.

import { ILogger } from '@theia/core';
import { FileUri } from '@theia/core/lib/node/file-uri';
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert, because you're importing a node module into a browser module.

@@ -112,8 +112,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, FileUri.fsPath(root.uri), opts);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an issue with the path handling in the search service? Should we move this conversion to the service implementation?

Could you point out, what's the real issue with given path on win?

Copy link
Member

Choose a reason for hiding this comment

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

fsPath has some special handling for windows: https://github.com/Microsoft/vscode-uri/blob/b1d3221579f97f28a839b6f996d76fc45e9964d8/src/index.ts#L955-L976

We can pass a URI instead and call FileUri.fsPath on the backend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlexTugarev, on Windows the search service passes a path with a leading slash to vscode-ripgrep. So searches always returns empty. FileUri.fsPath() fixes this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gonzalezw, we should not use FileUri in the browser code. We had a very similar issue with the file search (Ctrl/Cmd+P). Please look into that PR. Perhaps this is something we have to fix on the backend.

@gonzalezw
Copy link
Contributor Author

@kittaakos, I've update the PR to make the path conversion in the backend.

@kittaakos
Copy link
Contributor

@gonzalezw, awesome. Please squash your commits, and I restart the Windows build. The current failure is most likely unrelated to your change.

@gonzalezw
Copy link
Contributor Author

@kittaakos, I've squashed the commits

@kittaakos
Copy link
Contributor

kittaakos commented Sep 12, 2018

I have verified it on Windows (and on OS X too); it works nicely. Thank you!

Since we have switched from a path string to a URI string, can you please modify the API to reflect this change. Namely, I would like to ask you to change root to rootUri in the method signature here:

https://github.com/theia-ide/theia/blob/0f6d8e0bdd7060e049b12cf3a8f243347df45025/packages/search-in-workspace/src/common/search-in-workspace-interface.ts#L119

Edit: and on the implementation side as well. So if someone reads the code, it is clear what root rootUri is.

@@ -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 :)

@kittaakos
Copy link
Contributor

I've squashed the commits

Please squash again, @gonzalezw.

Signed-off-by: William Gonzalez <William.Gonzalez@arm.com>
@gonzalezw
Copy link
Contributor Author

@kittaakos, I've squashed.

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

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

I have verified 442345d on Windows. It works. Thank you for your help, @gonzalezw!

@kittaakos kittaakos merged commit 35b1a24 into eclipse-theia:master Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants