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

SaveAs functionality in Notebook API #97274

Closed
DonJayamanne opened this issue May 8, 2020 · 1 comment
Closed

SaveAs functionality in Notebook API #97274

DonJayamanne opened this issue May 8, 2020 · 1 comment
Assignees

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented May 8, 2020

Assume we have the following scenario:

  • NotebookA has been opened twice (side by side)
    • It is my understanding that extension authors need not worry about how many editors are opened for the same document.
    • Thats great
  • User starts executing all cells in NotebookA
  • Now user saves one of them as NotebookB.
  • At this point one of the Notebook is NotebookA and other is NotebookB & both are opened.

Questions

  • When invoking saveNotebookAs, will VS Code provide a completely new instance of NotebookDocument with Uri pointing to the new target resource?
    • I think it should.
    • Else updates to this NotebookDocument could impact both NotebookA and NotebookB
  • However creating a copy of NotebookDocument & passing this into saveNotebookAs might not always work
    • If user has just one notebook opened, then creating a copy will not work as output will not go into this same document (with different file name) while cells are being executed.
    • Feels like we should create copies only when there's one copy of the editor opened for a notebook document.
  • Other approaches,
    • Extension can disable stop execution when user performs a saveas.
      • However, we end up with similar situation as earlier.
      • We shouldn't stop execution if there is only one editor for NotebookA opened.
    • VS Code can disable save as while execution is in progress (don't think this is a good idea - not allowing user to save a file is just wrong)

@rebornix /cc

& thanks for the awesome work done by the VS Code team for adding this API.

@DonJayamanne
Copy link
Contributor Author

@rebornix
I'm closing this issue. Considering the fact that this will line up with Custom Editor and looking at existing behavior in Notebooks, I think we can handle this at our end (I'll file a separate issue for some other stuff).
From what I can tell the following happens:

  • User hits Save as
  • VS Code will close previous editor and open a new editor for the new target

This works for us, except we need to know whether editors associated with old file are still opened. Separate issue

@github-actions github-actions bot locked and limited conversation to collaborators Jun 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants