microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.87k stars 28.74k forks source link

Custom editor webviews should not be recreated on rename #86146

Open mjbvz opened 4 years ago

mjbvz commented 4 years ago

From #85991

Repo

  1. Using the .abc editor from https://github.com/mjbvz/vscode-experimental-webview-editor-extension/
  2. Create a file called x.abc. Open it
  3. With the custom editor for x.abc still open, rename x.abc file to y.abc in the VS Code file explorer

Bug Notice that the editor's webview is destroyed and then recreated. It would be preferable in this webview were kept alive across the rename (although perhaps only if the editor capabilities implement a rename method)

You can better confirm this by putting some sort of state into the webview, such as a script consisting of:

let i = 0;
setInterval(() => console.log(++i), 1000);
mjbvz commented 4 years ago

This was implemented by 041a5907b1d3437344fda16da784aba7828af520 for CustomTextEditor. Will discuss the api and look into hooking up CustomEditor as well this iteration

segevfiner commented 1 year ago

@mjbvz It seems that VS Code also forgets that it used to have a custom editor open for a file after a rename, so a non-default custom editor will get closed and replaced with a plain text editor.