Fix webview find widget not working after moving editor group to new window#269509
Open
magliocchetti wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix webview find widget not working after moving editor group to new window#269509magliocchetti wants to merge 1 commit intomicrosoft:mainfrom
magliocchetti wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Fixes microsoft#233044 When a webview panel with enableFindWidget is moved to a new window using "Move Editor Group into New Window", the find widget would appear but fail to highlight search results. The issue was that the WebviewFindWidget's context keys remained bound to the original window's context key service. When moved to a new window, the setContextKeyService method updated the webview's context service but not the find widget's internal context keys. This fix: - Adds updateContextKeyService() method to WebviewFindWidget to rebind the _findWidgetFocused context key when the context service changes - Updates WebviewElement.setContextKeyService() to propagate the context service update to the find widget The find widget now properly updates its context keys when moved between windows, allowing search functionality to work correctly. Signed-off-by: Giovanni Magliocchetti <giovimag123@gmail.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
Fixes a bug where webview find widgets stopped working after moving editor groups to new windows. The issue occurred because the find widget's context keys remained bound to the old window's context key service.
- Added
updateContextKeyService()method toWebviewFindWidgetto rebind context keys - Modified
WebviewElement.setContextKeyService()to propagate updates to the find widget - Changed
_findWidgetFocusedfrom readonly to mutable to support rebinding
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/vs/workbench/contrib/webview/browser/webviewFindWidget.ts |
Adds context key service update functionality and stores reference for later updates |
src/vs/workbench/contrib/webview/browser/webviewElement.ts |
Propagates context key service updates to the find widget |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #233044
This PR fixes an issue where webview panels with
enableFindWidgetenabled would stop working after being moved to a new window using the "View: Move Editor Group into New Window" command. The find widget would appear, but search results would not be highlighted in the webview.Root Cause
When a webview is moved to a new window,
setContextKeyService()is called to update the context key service to the new window's instance. However, theWebviewFindWidgetwas not updating its internal context keys. Specifically, the_findWidgetFocusedcontext key remained bound to the old window's context key service, causing the find functionality to break.Changes
webviewFindWidget.tsupdateContextKeyService()method that:_findWidgetFocusedcontext key_findWidgetFocusedto the new context key servicewebviewElement.tssetContextKeyService()to propagate context key service updates to the find widgetTesting
To verify the fix:
src/extension.tswith the code from the issue descriptionThis is a minimal, focused fix that follows the existing pattern for updating context keys when components move between windows.