-
Notifications
You must be signed in to change notification settings - Fork 29.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
Find in webview based views (html preview, release notes, extension editor) #30016
Find in webview based views (html preview, release notes, extension editor) #30016
Conversation
…o provide find for webviews
…o respect 'part' separation
} | ||
}); | ||
this.webview.style(this.themeService.getTheme()); | ||
this._themeChangeSubscription = this.themeService.onThemeChange(this.onThemeChange); |
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.
Not sure it matters here, but bind this
for this.onThemChange
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.
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.
Pretty cool! 😮 terminal side looks good to me. @rebornix should also check it out since he did the find ui in the terminal.
I think this also closes #29795 |
@Tyriar @mjbvz the webview find api supports case sensitivity and searching only from the start of the word (or treating capital letters inside words as the start of a word) for whole word search but not regex. It also gives info about the number of results and the position of the current result (shown in the closed PR). This should make it easy to keep the webview find at feature parity with the terminal find and/or reach feature parity with the normal find. I'd also be happy to help with that |
Issues found while playing with the code Find Previous button doesn't work when invoking second time in webiew editor
The first time when we invoke Find Widget and type, we have automatic searching. Whi.le if we dismiss it and then invoke again, it doesn't automatically research the document. Sometimes it even raises null reference exception. Esc should dismiss the Find Widget when the widget loses focus in webview editor
Right now in both editor and terminal, pressing Esc will close the find widget. Enter in Find input can only search once after launching the secondThis is different from the first issue. This time we always put the focus in find input box.
Lastly, it seems webview doesn't have any UI state persistence, switching to another editor and then switching back loses the Find Widget, but it's likely an existing issue. @mjbvz |
In overall it looks pretty neat and it's really useful :) Everything can be searchable. |
The build is also failing:
|
@rebornix Yes webviews themselves are not persistent by design. The htmlEditor which holds the webview is persisted so we should be able to save search state there and then restore it when the webview is shown again. Webview search persistence is not a blocking issue for this PR in my mind |
@hoovercj the module can't be found so I suspect you need to register |
…e focused. Aligns with full find widget
@Tyriar thanks for the pointer, hopefully I registered it correctly now. I also noticed that "ctrl+f" with the terminal find already opened and focus in the textinput would select the input. It would NOT do so if the focus was on the buttons. I did a bit more refactoring so that the webview find would do that too, and also so that both of them would work if it was pressed with the buttons focused. This aligns with the normal find widget.
The current iteration still will not begin searching when you reactivate the find widget until you start typing or press enter. This doesn't exactly match the editor find widget, but it matches Chrome's find and it is due to the way the webview find api works. The webview find api doesn't have a way to find without moving. I think when you see how it behaves in practice, though, you will see that the behavior is fine. However, if you are still seeing a null reference, please let me know :-) The other two issues you mentioned should also be fixed. |
…ensitive). Removed registration from workbench to see if it was necessary at all. If it fails again, I'll add it back
any idea what could cause this? I haven't touched this file |
@hoovercj Looks like an unrelated failure on master, try merging from master again. |
…lPreview/find/findInputBased
@Tyriar I guess you're right. Green :-) |
Thanks @hoovercj! This should be in the first VSCode 1.15 insiders build which should come out early next week after we ship 1.14 |
Great, I can't wait @mjbvz! And if there are bugs/issues associated with it, please do tag me in them and I'll try to fix them, or at the very least I'll be shamed into doing better next time :-) |
@mjbvz this PR replaces PR #22918 to address issue #2187.
I noticed that @Tyriar had essentially created a "simple find widget" to use in the terminal which was much simpler to reuse than trying to refactor the full "find widget".
I refactored that out into a reusable widget (SimpleFindWidget) and updated the terminal to use it (TerminalFindWidget).
I then created a WebviewFindWidget to be used by the webview to interact with the native webview find api. To respect the layering contract, I had to make the existing WebviewEditor into an abstract class and extend it in the correct layer so it could have access to the webview. HtmlPreviewPart and ReleaseNotesEditor now extend from that new WebviewEditor implementation and therefore both have access to the new find widget.
ExtensionEditor also now leverages the simple find widget to enable searching through readmes and release notes within the extension editor view.
Finally, I improved the styling of the simple find widget by adding "overflow: hidden" to the containers that use it so that it can properly be animated in.
Caveat: I don't know what HtmlEditorZone is so I didn't test that.
Here are gifs of it in action:
This is the find working in a markdown preview:
This is the find working in release notes
This is the find working the same as before in the terminal, but now with animation:
This is the find working in the webview sections of the ExtensionEditor