Currently, if a small change is made to the notebook and the save button is pressed, the entire underlying JSON will be converted to a condensed format (i.e. no newline breaks/indentations).
This is a particular issue for version control of notebooks and, ideally, changing a single word in the notebook, should only leave that word changed in the underlying text file.
At a minimum, it would be helpful if the JSON is saved with the standard 2 space indent format.
I think Jupyter Lab's default is set to 1 space indent.
Hmm, I think we'd need some way to have the user specify the format. Would Jupyter's default 2 space indent be sufficient?
I believe most editors save using the same 1 space default indentation. Classic saves in this format. Without the consistency this causes huge git conflicts on every save.
Another idea: retain the original space indentation while saving and default to 1 if it's a new file. Indentation editable through settings.json.
I think calculating the greatest common divisor of all whitespace prefixes would be a nice way.
Or should the original .ipynb be consisted of inconsistent indentation, choose the one that would affect least to a diff.
Another idea: retain the original space indentation while saving and default to 1 if it's a new file. Indentation editable through
settings.json.
That sounds good to me :)
In addition to the formatting, it actually modifies the metadata too: microsoft/vscode-jupyter#2919
This should be fixed in the insider's build now.
Validated. Created a small jupyter file directly. Checked the raw file. Opened in vscode Native Editor. Made a small change and saved. Raw file only has that small change.
Cheers 馃榾
Most helpful comment
Validated. Created a small jupyter file directly. Checked the raw file. Opened in vscode Native Editor. Made a small change and saved. Raw file only has that small change.