vscode-runme icon indicating copy to clipboard operation
vscode-runme copied to clipboard

Need better solution for updating name in response to cell content changes

Open mxsdev opened this issue 2 years ago • 5 comments

In #473, I introduced code that modifies the notebook document on save.

I recently ran into an issue where this makes it impossible to save the document, since the document modification itself makes the document need another save. In particular, it seems to happen to me in #564

I think we need a better solution for updating names based on content changes.

In the short-term, we should probably remove that code, so that people can save their documents properly.

cc @sourishkrout

mxsdev avatar May 31 '23 18:05 mxsdev

We can probably fix/salvage the implementation using the onWillSaveTextDocument event instead. It appears it was introduced for the exact use case where changes need to be handled before saving. Will require 1.77.x at the minimum.

https://github.com/microsoft/vscode/blob/main/src/vscode-dts/vscode.d.ts#L11776-L11796

sourishkrout avatar Jun 02 '23 18:06 sourishkrout

@sourishkrout

I tried that, but I was unable to get the unsaved file contents the way you can for a text document. In particular, I couldn't get the associated NotebookData with the NotebookDocument, which would be necessary for serialization.

I honestly think the easiest solution is to just re-implement the name generation code from go into javascript - would you be okay with this as a short-term solution?

mxsdev avatar Jun 05 '23 16:06 mxsdev

@sourishkrout

I tried that, but I was unable to get the unsaved file contents the way you can for a text document. In particular, I couldn't get the associated NotebookData with the NotebookDocument, which would be necessary for serialization.

I honestly think the easiest solution is to just re-implement the name generation code from go into javascript - would you be okay with this as a short-term solution?

Let's earmark this to chat about in person this week.

sourishkrout avatar Jun 05 '23 16:06 sourishkrout

@mxsdev this is fixed with the --index approach, no?

sourishkrout avatar Jul 19 '23 15:07 sourishkrout

@sourishkrout

It unblocks the issue, but the --index approach is still not ideal since the generated command is not very legible or re-usable as the document changes.

I think ideally, we would have a solution where the notebook provider can receive back information and update metadata after serialization, without requiring another deserialization.

mxsdev avatar Jul 19 '23 19:07 mxsdev