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

[7576]: Support for vscode.workspace.findTextInFiles API #7868

Merged
merged 1 commit into from
Jul 5, 2020

Conversation

nmorenor
Copy link
Contributor

@nmorenor nmorenor commented May 22, 2020

What it does

How to test

This was tested with the Codetogether extension since it does use this api.

  1. Install the extension
  2. Start a session via command palette.
  3. On the remote session on browser go to the search view.
  4. Search for some text in the workspace you should see search text results.

Alternatively you can use a test extension (https://github.com/Genuitec/theiatestsearch):

  1. Install the extension
  2. Invoke the SearchTest: Search from command palette and let the input box know what you are searchig for.
  3. On the Search test tree view contribution you should see the search results

Review checklist

Reminder for reviewers

@nmorenor
Copy link
Contributor Author

This fixes #7576

Copy link
Member

@vince-fugnitto vince-fugnitto left a 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:

  1. can you please update the pull-request description to follow the template? I'm not sure why parts were removed/omitted
  2. 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)
  3. 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/plugin/src/theia.d.ts Outdated Show resolved Hide resolved
packages/plugin/src/theia.d.ts Outdated Show resolved Hide resolved
@vince-fugnitto vince-fugnitto added the vscode issues related to VSCode compatibility label May 23, 2020
@akosyakov akosyakov added the search in workspace issues related to the search-in-workspace label May 25, 2020
Copy link
Member

@akosyakov akosyakov left a 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.

@nmorenor nmorenor force-pushed the master-7576-working branch from 9389ff9 to bc8abdf Compare May 25, 2020 17:20
@nmorenor
Copy link
Contributor Author

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.

@nmorenor nmorenor force-pushed the master-7576-working branch 4 times, most recently from 9dbf90f to 15d7cf9 Compare May 26, 2020 15:40
@nmorenor nmorenor requested a review from akosyakov May 26, 2020 15:46
@akosyakov
Copy link
Member

@vince-fugnitto Could you try please?

@akosyakov akosyakov requested a review from RomanNikitenko May 28, 2020 08:08
@vince-fugnitto
Copy link
Member

@vince-fugnitto Could you try please?

I tried using the second use-case (the .vsxi provided by the following extension) and it looked to work correctly. I was able to see results in the search-test widget when searching for terms.

@nmorenor nmorenor force-pushed the master-7576-working branch from 15d7cf9 to 1c7114d Compare June 4, 2020 19:00
@nmorenor nmorenor requested a review from akosyakov June 17, 2020 21:33
@akosyakov akosyakov requested a review from kittaakos June 24, 2020 07:26
@nmorenor
Copy link
Contributor Author

Right, that will be the implementation on VSCode

@kittaakos
Copy link
Contributor

I am verifying it with https://github.com/Genuitec/theiatestsearch.

  • I installed the extension to both Theia and VS Code. I have both Theia and VS Code opened on your PR as a workspace.
  • When I execute the SearchTest: Search and search for index, I have 152 results with Theia. In VS Code, I see 1242 results.

@kittaakos
Copy link
Contributor

kittaakos commented Jun 26, 2020

  • I have 152 results with Theia.

I see. You are limiting the hit counts to 150. It's a bug then.

Update: ✅ verified, works now.

@kittaakos
Copy link
Contributor

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:
screencast 2020-06-26 11-16-06
SIW works in Theia:
screencast 2020-06-26 11-18-29

} else if (defaultMaxHits < matches) {
resolve({ limitHit: true });
}
resolve({ limitHit: false });
Copy link
Contributor

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.

@kittaakos
Copy link
Contributor

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,
Copy link
Contributor

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> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be protected.

@kittaakos
Copy link
Contributor

I think I found the problem, the main issue here:

  • Search for something that does not hit the max count, it's important, your search won't be canceled,
  • Search for the same thing, you have duplicate results.

Please fix, and name me if you want a new review.

@nmorenor nmorenor force-pushed the master-7576-working branch from 1c7114d to 5646e5d Compare June 29, 2020 22:45
@nmorenor
Copy link
Contributor Author

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.

@nmorenor nmorenor requested a review from kittaakos June 29, 2020 22:48
@kittaakos
Copy link
Contributor

I found a difference; search for const index = , see that leading whitespaces are ignored in Theia.

VS Code:
Screen Shot 2020-06-30 at 08 41 02

Theia:
Screen Shot 2020-06-30 at 08 41 15

@kittaakos
Copy link
Contributor

👍 It works nicely; one remark on the behavior and some minor formatting issues.

packages/plugin/src/theia-proposed.d.ts Show resolved Hide resolved
@@ -539,7 +539,6 @@ export interface CallHierarchyOutgoingCall {
to: CallHierarchyItem;
fromRanges: Range[];
}

Copy link
Contributor

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.

@nmorenor nmorenor force-pushed the master-7576-working branch from 5646e5d to bd53574 Compare June 30, 2020 15:29
@nmorenor
Copy link
Contributor Author

@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

Screen Shot 2020-06-30 at 10 26 30 AM

I see this when I attach to the Host plugin while running on Debug.

@nmorenor nmorenor requested a review from kittaakos June 30, 2020 15:40
@nmorenor nmorenor force-pushed the master-7576-working branch from 463b47e to 3ba0e2f Compare July 2, 2020 16:06
@nmorenor
Copy link
Contributor Author

nmorenor commented Jul 2, 2020

Ok, now the tree also display the trailing whitespaces, I did add a new css class inside sidebar.css noWrapInfoTree I did not wanted to move the other one, because it could take effect on other parts of the UI.

Signed-off-by: Ignacio Moreno <ignacio@genuitec.com>
@kittaakos
Copy link
Contributor

Ok, now the tree also display the trailing whitespaces, I did add a new css class inside sidebar.css noWrapInfoTree I did not wanted to move the other one, because it could take effect on other parts of the UI.

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.

@nmorenor nmorenor force-pushed the master-7576-working branch from 3ba0e2f to 4e2c39a Compare July 2, 2020 16:13
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.

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!

@akosyakov akosyakov merged commit 7a88d28 into eclipse-theia:master Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
search in workspace issues related to the search-in-workspace vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for vscode.workspace.findTextInFiles API
4 participants