Skip to content

Set override to false when reopening editors after dragging them to a different editor group - #114093

Merged
Matt Bierner (mjbvz) merged 1 commit into
microsoft:masterfrom
hediet:hediet/dragging-custom-editor-fix
Jan 11, 2021
Merged

Matt Bierner (mjbvz) merged 1 commit into
microsoft:masterfrom
hediet:hediet/dragging-custom-editor-fix

Conversation

@hediet

Copy link
Copy Markdown
Member

This seems to fix #109000.

4e19bbb3-0e7c-412b-8630-b0ccedcd4759

Apparently this also prevents custom editor webviews from being recreated when they are moved to a different editor group 🎉
This is the behavior without this patch (notice the slow loading times):

664eda65-2ca7-4d0c-8e3c-413734cd86a4

This is with this patch (no loading times anymore at all):

47e10a5c-9b4b-4744-b1e4-b14fda1fa5e8

It seems like this enables all webviews to be dragged around with zero costs which would be super awesome 😮

webview

This was not that smooth before - the entire webview used to reload!

I only understand a tiny fraction of the custom editor logic, so this fix might have undesired consequences though.

Off-topic

It seems to me that the custom editor contribution is very complicated. I found the override mechanism to be hard to follow and to debug and after some debug sessions, I thought #109000 was nothing that could be easily fixed by the community.

From my understanding, this is a part of the control flow when a new custom editor is opened:

  1. DelegatingEditorService.openEditor is called by the UI and calls
  2. EditorGroupView.openEditor which triggers the event EditorGroupView.onWillOpenEditor and thus the listener
  3. EditorService.onGroupWillOpenEditor, which notifies all open editor handlers, including
  4. CustomEditorContribution.onEditorOpening/.onResourceEditorOpening, which calls
  5. CustomEditorService.openWith/.openEditorForResource, which calls
  6. EditorService.openEditor which calls then again (recursively, see (2), but with different arguments)
  7. EditorGroupView.openEditor which again triggers the EditorGroupView.onWillOpenEditor event and the listener
  8. EditorService.onGroupWillOpenEditor, which notifies all open editor handlers again, again including
  9. CustomEditorContribution.onEditorOpening, which stops, as the editor already is a CustomEditorInput.

If I got it correctly, a FileEditorInput is always created in this scenario, and sometimes, custom editors prevent the file editor from being rendered by creating their own CustomEditorInput and recursively calling EditorService.openEditor to show this input.
I'm curious (with my very limited understanding) - what is the advantage of this design over just having default editors and custom editors both being specializations of some abstract editor view? This would get rid of the recursion. I don't find it trivial at all that a simple override: false fixes this issue.

@mjbvz

Copy link
Copy Markdown
Contributor

Thanks!

The custom editor logic is complicated because custom editors were bolted into a codebase that was built around text editors (and the assumption that every resource has a single editor, instead of multiple potential editors)

@github-actions github-actions Bot locked and limited conversation to collaborators Feb 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editors Don't Remember "Open With..." Selection When Dragged

2 participants