Skip to content
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

Allow multiple editors for same file #9369

Conversation

colin-grant-work
Copy link
Contributor

@colin-grant-work colin-grant-work commented Apr 16, 2021

What it does

This PR fixes #3857 by allowing multiple editors to be opened for the same URI.

The basic principle is that all widget creation calls that go through the EditorManager add a counter field to the widget options so that the widget manager creates separate widgets for separate counter entries. The get calls use an existing counter value; getOrCreate an old if available, a new if necessary; and openToSide always creates a new value to ensure that a new widget is created.

How to test

  1. I've added a set of commands to split the view in various directions. Open an editor and run them. Each new editor should look like its parent: same visible range and selection.

image

  • In VSCode only one copy of an editor widget can exist on the same tabbar. If you create a new instance to the side and then move it to its parent's tabbar, one of them will be closed. I haven't tried to replicate that functionality here, but if it seems desirable, I can.

Review checklist

Reminder for reviewers

Signed-off-by: Colin Grant colin.grant@ericsson.com

@colin-grant-work colin-grant-work added the editor issues related to the editor label Apr 16, 2021
@colin-grant-work colin-grant-work force-pushed the feature/same-file-multi-editor branch from 5ebf60f to 2909df5 Compare April 19, 2021 14:21
@colin-grant-work colin-grant-work marked this pull request as ready for review April 19, 2021 14:43
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified the changes and they look really good 👍 we now support splitting the same editor URI multiple times.

Do we plan on supporting different editors in the pull-request, or do we keep it for subsequent updates? (for example diff-editors):

split-diff.mp4

@colin-grant-work
Copy link
Contributor Author

Do we plan on supporting different editors in the pull-request, or do we keep it for subsequent updates? (for example diff-editors):

Happy to take a look at how other editors are initialized and try to accommodate them. I'll see about diff editors today - any other editor types you're interested in?

@vince-fugnitto
Copy link
Member

Happy to take a look at how other editors are initialized and try to accommodate them. I'll see about diff editors today - any other editor types you're interested in?

I'm thinking anything which makes sense and is handled by editor-manager. For example, I tried with rendered previews (markdown) and it does not split which is correct. The diff is one example I am aware of.

@colin-grant-work colin-grant-work force-pushed the feature/same-file-multi-editor branch from 2909df5 to 5875dc0 Compare April 20, 2021 14:24
@colin-grant-work
Copy link
Contributor Author

Turns out I was just using a bad strategy to get the URI. I've replaced editorWidget.editor.getResourceUri() with just editorWidget.editor.uri, and that handles normal and diff editor directly.

image

@colin-grant-work colin-grant-work force-pushed the feature/same-file-multi-editor branch from 5875dc0 to ed8a833 Compare April 20, 2021 14:45
Signed-off-by: Colin Grant <colin.grant@ericsson.com>
@colin-grant-work colin-grant-work force-pushed the feature/same-file-multi-editor branch from ed8a833 to 16ca869 Compare April 20, 2021 14:46
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified the changes under multiple use-cases and it works very well:

  • confirmed that we can successfully split editors (standard editors, diff).
  • editor state is preserved on split.
  • confirmed that the 'split' commands work successfully.
  • confirmed that the two keybindings work successfully.
  • confirmed the following use-cases work for day-to-day use:
    • search and replace with multiple duplicate editors.
    • decorations for duplicate editors.
    • problem markers for duplicate editors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor issues related to the editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[editor] Support editing the same file in multiple editors?
2 participants