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

[CustomTextEditor extensions] Untitled document content is lost when doing "Reopen with..." custom text editor #150142

Open
Ark-kun opened this issue May 23, 2022 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug custom-editors Custom editor API (webview based editors)
Milestone

Comments

@Ark-kun
Copy link

Ark-kun commented May 23, 2022

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.67.2
  • OS Version: Windows 10

When doing "Reopen with... Cat Scratch" on untitled file, the content is lost

Steps to Reproduce:

  1. Open the https://github.com/microsoft/vscode-extension-samples/tree/0d36653b0da5041f49fe049e34f6d8671f8e1002/custom-editor-sample
  2. Augment the catScratchEditor.ts updateWebview code to add logging: console.log("updateWebview called. Document length = " + document.getText().length);
  3. Press F5 to debug the extension.
  4. Double-click on the tab bar to open new "Untitled 1" tab.
  5. Paste valid catScratch content:
{
  "scratches": [
    {
      "id": "8lYOoWqz2rHtPuhvnZ43eMx1mG6WnFrm",
      "text": "😸",
      "created": 1584577931699
    },
    {
      "id": "aZ57bJUEaXZ5wuBAX6NfGuj85Y6iw84N",
      "text": "😻",
      "created": 1584577933329
    }
  ]
}
  1. Use "Reopen with..." / "Cat Scratch" on the "Untitled 1" file.
  2. Observe: That the editor has no scratches
  3. Observe "updateWebview called. Document length = 0" in the log. The document content got lost

I expect the untitled document content to be preserved when reopening with custom editor.

2022-05-22.18-15-33.mp4
@VSCodeTriageBot
Copy link
Collaborator

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.67.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@mjbvz
Copy link
Contributor

mjbvz commented May 23, 2022

One bug per issue

Just tracking the first one here. Please open separate issues for the others

@Ark-kun Ark-kun changed the title [CustomTextEditor extensions] Multiple bugs related to working with untitled files [CustomTextEditor extensions] Untitled document content is lost when doing "Reopen with..." custom text editor May 24, 2022
@Ark-kun
Copy link
Author

Ark-kun commented May 24, 2022

Please open separate issues for the others

Done.

@mjbvz mjbvz added bug Issue identified by VS Code Team member as probable bug custom-editors Custom editor API (webview based editors) labels Dec 5, 2022
@mjbvz mjbvz added this to the Backlog milestone Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug custom-editors Custom editor API (webview based editors)
Projects
None yet
Development

No branches or pull requests

3 participants