Allow opening changes for files associated with custom editors #13916
+665
−162
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.
What it does
Allows the user to visually compare two versions of a file that is associated with a custom editor. This is done by opening both versions of the file simultaneously in a side-by-side editor, with each version being opened in a separate custom editor contained in the side-by-side editor.
For example, this feature can be used to help spot the differences between two versions of an image file associated with the custom editor contributed by the VS Code
media-preview
plugin, as illustrated with the following screenshot:More screenshots illustrating this feature being used with other custom editors:
This PR contains a series of individual commits that work together to make it possible for the
CustomEditorOpener
to open a diff-uri in a side-by-side editor containing the correspondingCustomEditor
s. While the main functionality is contributed by the latest commit, the earlier commits provide various fixes and enhancements required to make it work.Here is the sequence of commits:
Fix loading of webview resources that depend on query params
Some resource url (notably git) use the query part of the url to store additional information. The query part of the url was incorrectly being dropped while attempting to load these resources inside of webviews.
Fix
Error: Unknown Webview
messages in the logFix design and implementation issues surrounding
CustomEditorOpener
This commit ensures that the promise returned by
CustomEditorOpener.open
will only resolve to a properly initialized and openedCustomEditorWidget
. In particular, it ensures that the widget is opened according to the specifiedWidgetOpenerOptions
, includingwidgetOptions.ref
andmode
.Essentially, it revises the work done in Fix #9670: Custom editor plugin activation called 3 times when double click quickly #9671 and Fix the widget options when opening a VSCode Custom Editor #10580.
Restore custom editors as part of layout
Fixes an incorrect assumption that a custom editor cannot be restored if no
WebviewPanelSerializer
is registered for its view type. (Actually, custom editors are created and restored using a custom editor provider.)Also, ensures that
CustomEditorWidget.modelRef
satisfies the shape for theCustomEditorWidget
defined ineditor.ts
and cannot returnundefined
. (However,CustomEditorWidget.modelRef.object
can beundefined
until the custom editor is resolved.)Fixes custom-editor: restore editor as part of layout #10787
Fix a race condition when file system provider is activated
When file system provider is activated, wait until it is registered.
git: add support for custom editors
Uses
OpenerService
instead ofEditorManager
to open editorsContributes a
FileSystemProvider
for git-resourcesFixes an issue with getting blob contents
custom editor: open a diff-uri in a side-by-side editor
CustomEditorOpener
is now able to open a diff-uri in a side-by-side editor, which contains the correspondingCustomEditor
s.Fixes [Diff] Images should open in preview #9079
How to test
There are various configurations that can be used for testing this feature:
Windows vs. Linux vs. macOS
Browser vs. Electron
vscode.git
vs. (now deprecated)@theia/git
This feature can be tested with any custom editor.
A basic test scenario involves making a change to a file associated with a custom editor (e.g.,
.jpg
,.png
,.pawDraw
, or.cscratch
) and then opening changes in a side-by-side editor by clicking on the file in the Source Control view.Since this PR also fixes an issue with custom editors not being restored as part of layout, it is worth checking out that custom editors are now correctly restored, both standalone and as part of side-by-side editors.
Also, it is important to verify that there are no regressions, especially that standalone custom editors can still be opened and work as expected.
Review checklist
Reminder for reviewers