-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Add onWillSaveNotebookDocument #157844
Comments
Is anyone asking for this specifically? |
@Yoyokrazy and I discussed as a way to clean up unused attachments in notebooks. For this we need to loop through all attachments in the notebook and remove them from the metadata if they are not referenced in the cell's markdown We also talked about cleaning up these attachments when the notebook is closed. However that means we would need an api to modify notebooks when they are closed, which raises many more questions |
@jrieken I am asking for it! It'd be very useful, thanks! Related PR/issue: codefori/vscode-ibmi#818 (comment) |
@bpasero do we have a generic save participants for any working copy? |
@jrieken yeah I think I had added that even though no client yet, can you try via |
Note from API discussion: when looking into this, we should also look into format on save for notebooks |
We would use this in nbdev (tracking here: AnswerDotAI/nbdev#952). We remove unneeded metadata from notebooks on-save, for cleaner diffs and less chance of merge conflicts. It's very easy to implement with Jupyter Notebook/Lab via def nbdev_clean_jupyter(**kwargs):
try: from nbdev.clean import clean_jupyter
except ModuleNotFoundError: return
clean_jupyter(**kwargs)
c.ContentsManager.pre_save_hook = nbdev_clean_jupyter How could we get similar behaviour for our VSCode users? Is there any workaround while |
We introduced a proposed api export interface NotebookDocumentWillSaveEvent {
/**
* A cancellation token.
*/
readonly token: CancellationToken;
/**
* The document that will be saved.
*/
readonly document: NotebookDocument;
/**
* The reason why save was triggered.
*/
readonly reason: NotebookDocumentSaveReason;
waitUntil(thenable: Thenable<readonly WorkspaceEdit[]>): void;
waitUntil(thenable: Thenable<any>): void;
} Additional edits before save can be returned through |
Based on the comment from @mjbvz , we can simply the API to
Two changes:
|
The API is finalized and merged into |
This would match
onWillSaveTextDocument
but for notebook docs insteadAs parts of this, we should allow extensions to perform notebook edits before the save happens
The text was updated successfully, but these errors were encountered: