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

Reopen Editor with breaks --wait behavior #111187

Closed
eamodio opened this issue Nov 23, 2020 · 5 comments
Closed

Reopen Editor with breaks --wait behavior #111187

eamodio opened this issue Nov 23, 2020 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug custom-editors Custom editor API (webview based editors) help wanted Issues identified as good community contribution opportunities *not-reproducible Issue cannot be reproduced by VS Code Team member as described workbench-cli VS Code Command line issues
Milestone

Comments

@eamodio
Copy link
Contributor

eamodio commented Nov 23, 2020

Because Reopen Editor with seems to close the current document, and re-open it again in with the new editor, this break the --wait behavior. IMO, switching editors, shouldn't cause the document to be closed/opened nor break --wait

FYI, this causes issues for the new GitLens rebase editor, as it relies on the --wait behavior.

@mjbvz mjbvz added custom-editors Custom editor API (webview based editors) workbench-cli VS Code Command line issues help wanted Issues identified as good community contribution opportunities labels Nov 25, 2020
@mjbvz mjbvz added this to the Backlog milestone Nov 25, 2020
@lramos15
Copy link
Member

lramos15 commented Jun 2, 2021

/cc @bpasero For more weird --wait cases. This is because internally a replace is just an open -> close which triggers the wait

@bpasero
Copy link
Member

bpasero commented Jun 5, 2021

When we detect --wait we install a listener to observe editors closing, e.g. here:

await this.instantiationService.invokeFunction(accessor => whenEditorClosed(accessor, resourcesToWaitFor));

To then delete a wait marker file which the calling side polls on for deletion before returning:

await this.fileService.del(waitMarkerFile);

The code for observing editors closing probably needs to be made more clever around the fact that editors can reopen:

const listener = editorService.onDidCloseEditor(async event => {

Currently we just listen to onDidCloseEditor which will fire even for the reopen case.

Some ideas:

  • enrich the IEditorCloseEvent to carry a boolean that can be used to figure out if the editor was closed because it was reopened
  • instead of reacting to the close event directly, add some debouncing to give the reopen a chance to bring up the new editor

Not a big fan of the debouncing because that solution sounds fragile to me. A property would make more sense to me.

Note that we already have a replaced property on IEditorCloseEvent which maybe is a bit misleading: it does not tell whether the editor was replaced from a replaceEditors call, but rather indicates that the editor was in preview mode and got replaced because another editor was opened (here). Maybe the property could still be reused though.

@bpasero
Copy link
Member

bpasero commented Sep 17, 2021

Given my recent change in this area, if we were to enrich EditorCloseContext with another context for the reopen, we can easily fix this:

export enum EditorCloseContext {

@lramos15
Copy link
Member

Given my recent change in this area, if we were to enrich EditorCloseContext with another context for the reopen, we can easily fix this:

export enum EditorCloseContext {

This sounds like a good solution

@mjbvz mjbvz added the bug Issue identified by VS Code Team member as probable bug label Oct 11, 2021
@lramos15
Copy link
Member

Tested this and it seems the REPLACE closed context is passed in the wait works properly.

@lramos15 lramos15 added the *not-reproducible Issue cannot be reproduced by VS Code Team member as described label Dec 20, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug custom-editors Custom editor API (webview based editors) help wanted Issues identified as good community contribution opportunities *not-reproducible Issue cannot be reproduced by VS Code Team member as described workbench-cli VS Code Command line issues
Projects
None yet
Development

No branches or pull requests

4 participants