Skip to content

Revisit custom editor input factory #117208

Closed

Description

While working on #116856 I spent some though on the custom editor input factory. The only usecase today seems to be for restoring backups (via BackupRestorer).

I would think that a better place for this would be IEditorService#createEditorInput and the backup restorer should just use that. If we need to make this method async for a few usecases I think that is OK, as long as the signature could stay sync for most typical uses.

Overall I think we should merge the ICutomEditorInputFactory into the existing IEditorInputFactory and not have 2 concepts.

Activity

  1. added
    debt
    custom-editors
    on Feb 22, 2021
  2. bpasero commented on Mar 1, 2021

    @bpasero
    ContributorAuthor
  3. jrieken commented on Mar 1, 2021

    @jrieken
    Contributor
  4. jrieken commented on Mar 1, 2021

    @jrieken
    Contributor

    and related to #117873

  5. jrieken commented on Mar 2, 2021

    @jrieken
    Contributor

    Yes, I have to say that I can't wrap my head around this. I don't understand why notebooks must register a IEditorInputFactory and ICustomEditorInputFactory and I am failing to fix #117899 because not of this is intuitive to me.

    Isn't the idea of an editor input to abstract away editors? And isn't an input factory a way to revive a serialised input into an alive object? That sounds a like pretty good abstraction and something must be very wrong with it if we now require the same abstraction again, just for custom editors.

  6. added
    important
    on Mar 2, 2021
  7. jrieken commented on Mar 2, 2021

    @jrieken
    Contributor

    Marking all of this as important because this is crucial to the notebooks effort and playing the catch-up game of copy-pasting source code isn't sustainable.

  8. added
    workbench-editors
    on Mar 3, 2021
  9. lramos15 commented on Mar 22, 2021

    @lramos15
    Member

    Benjamin Pasero (@bpasero) We should probably set up another meeting to discuss this as I don't think there's a good solution here. After discussion we weren't able to merge these ideas.

  10. bpasero commented on Mar 23, 2021

    @bpasero
    ContributorAuthor

    Yeah I think this might need some more discussion with custom editor + notebook people why the viewType is needed so early on for the editor input to work.

    To follow up on Johannes Rieken (@jrieken) point:

    Isn't the idea of an editor input to abstract away editors? And isn't an input factory a way to revive a serialised input into an alive object? That sounds a like pretty good abstraction and something must be very wrong with it if we now require the same abstraction again, just for custom editors.

    Yes exactly, an editor input should be sufficient to open an editor and it shouldn't require an async lookup into backups. The flow should be:

    • editor input gets created (either from a backup that was found or because it was opened previously)
    • editor opens (text, notebook or custom)
    • in the resolve method you can do the actual lookup of what view type is needed

    One thing that is special here is that the need for the custom editor input factory only applies to one case:

    • you open a folder and make editors dirty (text, custom, notebooks)
    • you close that window and exit without saving
    • from the command line you type code <folder> <file>
    • we only open the file and do not restore the other editors
    • but we still of course want to restore all editors that are dirty so we need this complicated flow of knowing how to actually create the inputs

    Logan Ramos (@lramos15) maybe we can actually solve this differently in the end: if an editor ends up as backup it must be opened and as such we must have it as UI state somewhere. Instead of doing this complicated dance with the custom editor input factory, we can try to get the editor from that UI state instead. We can also think about simply restoring all previously opened editors as soon as we detect any dirty editor. In any case we can probably get rid of the custom editor input factory entirely 👍

    I think we should tackle this for April and not have it on the Backlog.

  11. lramos15 commented on Apr 20, 2021

    @lramos15
    Member

    Johannes Rieken (@jrieken) I'm removing the important label as I think we have at least blocked the catchup game with the new editorOverrideService.

    Benjamin Pasero (@bpasero) Do you still want to try to tackle this in April? I'm not sure how important it is. It doesn't really improve the usability of the editorOverrideService from my understanding as we never operate on the backup case.

  12. removed
    important
    on Apr 20, 2021
  13. bpasero commented on Apr 21, 2021

    @bpasero
    ContributorAuthor

    Will update here once I looked into how to restore backups with the new typeId support.

  14. added
    unreleased
    insiders-released
    and removed
    unreleased
    on May 10, 2021
  15. locked and limited conversation to collaborators on Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

custom-editorsdebtinsiders-releasedworkbench-editors

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions