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 to store/resume open editors across Continue On transitions #193704

Open
joyceerhl opened this issue Sep 21, 2023 · 4 comments · Fixed by #201631
Open

Allow to store/resume open editors across Continue On transitions #193704

joyceerhl opened this issue Sep 21, 2023 · 4 comments · Fixed by #201631
Assignees
Labels
feature-request Request for new features or functionality workbench-editors Managing of editor widgets in workbench window workbench-state UI state across restarts
Milestone

Comments

@joyceerhl
Copy link
Contributor

Split out from #183449

@joyceerhl joyceerhl added the feature-request Request for new features or functionality label Sep 21, 2023
@joyceerhl joyceerhl added this to the September 2023 milestone Sep 21, 2023
@bpasero bpasero added workbench-editors Managing of editor widgets in workbench window workbench-state UI state across restarts labels Sep 21, 2023
@bpasero bpasero modified the milestones: October 2023, On Deck Oct 14, 2023
@bpasero
Copy link
Member

bpasero commented Dec 20, 2023

For editors, we use a Memento to store and restore editor state. We currently use StorageTarget.MACHINE and would have to change that to StorageTarget.USER:

private readonly workspaceMemento = this.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);

Mementos are just simple wrappers around the storage service that make it a bit easier to work with.

The state of editors begins to be created here:

const uiState: IEditorPartUIState = {
serializedGrid: this.gridWidget.serialize(),
activeGroup: this._activeGroup.id,
mostRecentActiveGroups: this.mostRecentActiveGroups
};

Serialising the grid translates to a call to toJSON for each node:

toJSON(): ISerializedEditorGroupModel {
return this.model.serialize();
}

Each editor of a editor group has its own serialiser that is called:

const value = editorSerializer.serialize(editor);

I count around 20 serialisers that each own how the data is serialised.

image

The one for files has this shape:

const serializedFileEditorInput: ISerializedFileEditorInput = {
resourceJSON: resource.toJSON(),
preferredResourceJSON: isEqual(resource, preferredResource) ? undefined : preferredResource, // only storing preferredResource if it differs from the resource
name: fileEditorInput.getPreferredName(),
description: fileEditorInput.getPreferredDescription(),
encoding: fileEditorInput.getEncoding(),
modeId: fileEditorInput.getPreferredLanguageId() // only using the preferred user associated language here if available to not store redundant data
};

@joyceerhl in this case where resource.toJSON() is used, how would we support continue on, given its not the URI verbatim but already the JSON form?

@bpasero
Copy link
Member

bpasero commented Dec 20, 2023

Actually, this may be fine, URI.toJSON puts the $mid marker that I think we use:

const res = <UriState>{
$mid: MarshalledId.Uri
};

@alexandruavadanii
Copy link

Hi,
Thank you for working on yet another nice feature!

I wonder whether this will also cover custom URI schemes handled by TextDocumentContentProvider. While not being a major problem, I always saw the read-only editors being silently discarded, even without using the "continue on" functionality and just reloading the current workspace.

If that's out of scope here, I can create a separate issue and try to better describe my use-case, maybe even provide a simple demo for testing.

@bpasero bpasero modified the milestones: On Deck, December / January 2024 Jan 4, 2024
bpasero added a commit that referenced this issue Jan 4, 2024
…#193704) (#201631)

* Allow to store/resume open editors across Continue On transitions (fix #193704)

* address feedback
@vscodenpa vscodenpa added the unreleased Patch has not yet been released in VS Code Insiders label Jan 4, 2024
@bpasero bpasero reopened this Jan 4, 2024
@vscodenpa vscodenpa removed the unreleased Patch has not yet been released in VS Code Insiders label Jan 4, 2024
@bpasero
Copy link
Member

bpasero commented Jan 4, 2024

In my testing, I can see how editors restore but with the original URI and not the transformed one. This means that somehow the URI transformation does not take place.

@joyceerhl can you continue to investigate.

@bpasero bpasero modified the milestones: December / January 2024, February 2024 Jan 20, 2024
@bpasero bpasero modified the milestones: February 2024, March 2024 Feb 19, 2024
@bpasero bpasero modified the milestones: March 2024, Backlog Mar 14, 2024
@bpasero bpasero removed their assignment May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality workbench-editors Managing of editor widgets in workbench window workbench-state UI state across restarts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants