-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[7576]: Support for vscode.workspace.findTextInFiles
API
#7868
Conversation
This fixes #7576 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nmorenor thank you for your contribution, I have some general comments:
- can you please update the pull-request description to follow the template? I'm not sure why parts were removed/omitted
- can you please provide more meaningful steps on 'how to test' so reviewers can more easily test the changes (this can be a minimal custom extension for test purposes)
- I'm not sure about the changes as they are proposed. They will likely be updated until they are finalized and that means that potential major refactoring are necessary. My previous comment still holds true: Support for
vscode.workspace.findTextInFiles
API #7576 (comment)
packages/search-in-workspace/src/browser/search-in-workspace-service.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's important that for VS Code compatibility we don't invent anything, but port VS Code code
It would be helpful if you could point to implementation in VS Code. For such copied code we also need CQs usually.
packages/search-in-workspace/src/browser/search-in-workspace-service.ts
Outdated
Show resolved
Hide resolved
packages/search-in-workspace/src/common/search-in-workspace-interface.ts
Outdated
Show resolved
Hide resolved
9389ff9
to
bc8abdf
Compare
I'm not sure what is a CQ but here are the orignal interfaces for the API from VSCode. https://github.com/microsoft/vscode/blob/f5d10326f5ef42eb7b6e3a3ce7a50baa3c7d7ed4/src/vs/vscode.proposed.d.ts these had to be the same so I bring those interfaces to this change. |
packages/search-in-workspace/src/common/search-in-workspace-interface.ts
Outdated
Show resolved
Hide resolved
packages/search-in-workspace/src/browser/search-in-workspace-service.ts
Outdated
Show resolved
Hide resolved
9dbf90f
to
15d7cf9
Compare
@vince-fugnitto Could you try please? |
I tried using the second use-case (the |
15d7cf9
to
1c7114d
Compare
Right, that will be the implementation on VSCode |
I am verifying it with https://github.com/Genuitec/theiatestsearch.
|
I see. You are limiting the hit counts to 150. It's a bug then. Update: ✅ verified, works now. |
I found another regression, search for körte with the search-in-workspace (SIW) (Ctrl/⌘+Shift+F) you have to see one single hit if you opened Theia as a workspace. Use your test extension in VS Code, and search for körte again, and again. You will have one single result. 👍 Now, do the same in Theia: |
} else if (defaultMaxHits < matches) { | ||
resolve({ limitHit: true }); | ||
} | ||
resolve({ limitHit: false }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's clean this up, and move the resolve({ limitHit: false });
into an else
.
Hmm, the hit-count feels random. Search for "foo" with SIW, I see 542 results, do the same with your test extension, I see 160 results. |
uri: URI.parse(result.fileUri), | ||
preview: { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
text: isObject(next.lineText) ? (<any>next.lineText).text : <string>next.lineText, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be a type-guard for string | LinePreview
? If so, let's simplify to text: typeof next.lineText === 'string' ? next.lineText : next.lineText.text,
or use a proper type-guard and get rid of the any
.
return this.doSearch(what, roots.map(r => r.uri), callbacks, opts); | ||
} | ||
|
||
private async doSearch(what: string, rootsUris: string[], callbacks: SearchInWorkspaceCallbacks, opts?: SearchInWorkspaceOptions): Promise<number> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be protected
.
I think I found the problem, the main issue here:
Please fix, and name me if you want a new review. |
1c7114d
to
5646e5d
Compare
Just pushed the fixes for @kittaakos observations. Thanks for the review, I did not notice these issues, since I was just doing one search test. |
👍 It works nicely; one remark on the behavior and some minor formatting issues. |
@@ -539,7 +539,6 @@ export interface CallHierarchyOutgoingCall { | |||
to: CallHierarchyItem; | |||
fromRanges: Range[]; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's revert this change.
5646e5d
to
bd53574
Compare
@kittaakos Formatting issues have been fixed also reverted the remove of line on plugin-api-rpc-model.ts Now regarding the white spaces on the Theia, it looks like the search does return the line text with the white spaces there but somehow the UI is hiding the trailing white spaces. The extension does have a console.log for each returned result and in there I do see the trailing spaces but somehow they are not rendered on the UI. Perhaps that can be looked on a different PR? Here a Screen Shot of the console.log I see this when I attach to the Host plugin while running on Debug. |
463b47e
to
3ba0e2f
Compare
Ok, now the tree also display the trailing whitespaces, I did add a new css class inside sidebar.css |
Signed-off-by: Ignacio Moreno <ignacio@genuitec.com>
Wow, great 👍 I did not expect you to fix the tree too, but thank you! I'll take a look tomorrow, and will merge the changes. |
3ba0e2f
to
4e2c39a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new feature works very well; I had the same behavior and UX as in VS Code with the sample extension. Thank you for your contribution, @nmorenor 👍
@akosyakov, can you please press the merge button if you are fine with the RPC API and model changes. Thanks!
What it does
vscode.workspace.findTextInFiles
API #7576: Provides ability to execute the vscode api vscode.workspace.findTextInFilesHow to test
This was tested with the Codetogether extension since it does use this api.
Alternatively you can use a test extension (https://github.com/Genuitec/theiatestsearch):
Review checklist
Reminder for reviewers