Need better solution for updating name in response to cell content changes
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
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
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?
@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
NotebookDatawith theNotebookDocument, 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.
@mxsdev this is fixed with the --index approach, no?
@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.