vscode-jupyter changes cells that were not modified: removes \n at the end of every "image/png" field
See original GitHub issueEnvironment data
- VS Code version: Version: 1.61.1, commit c13f1abb110fc756f9b3a6f16670df9cd9d4cf63
- Jupyter Extension version (available under the Extensions sidebar): v2021.9.1101343141
- Python Extension version (available under the Extensions sidebar): v2021.10.1336267007
- OS (Windows | Mac | Linux distro) and version: OS: Darwin x64 19.6.0
- Python and/or Anaconda version: 3.8.12
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
- Jupyter server running: Local
Expected behaviour
When opening in VSCode a Jupyter notebook created using Jupyter Notebook or Jupyter Lab and making a tiny change to one cell, then saving the notebook, the other cells in the notebook should not be modified.
Actual behaviour
Every cell that outputs an image (e.g., using Matplotlib) is modified. Specifically, the \n
at the end of every "image/png"
field is removed. This makes switching between VSCode and Jupyter Notebook/Lab very painful, especially when working with git, as even minor changes lead to large diffs.
Steps to reproduce:
- Create a notebook with Jupyter Notebook or Jupyter Lab, and run the following code:
import matplotlib.pyplot as plt
plt.plot([1,2,3], [3, 1, 2])
plt.show()
- Save the notebook. You can verify that the
"image/png"
field has a\n
at the end. - Open the notebook in VScode, make a tiny modification without running the notebook or modifying the existing cells (e.g., add a markdown cell).
- Save the notebook. You can verify that the
"image/png"
field no longer has a\n
at the end. It was modified even though we didn’t touch it.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
January 2022 (version 1.64) - Visual Studio Code
We made some changes to make it more obvious when a cell is executing, and which cell is executing. First, when a cell...
Read more >11 Practical Tips You Need to Know to Personalize Jupyter ...
If you want to try a new taste in running your python code in Jupyter Notebook (hereafter; Jupyter), you can change and personalize...
Read more >Advanced Visual Studio Code for Python Developers
As a Python developer, a lot of the commands you'll use in Visual Studio Code are provided from extensions, similar to the Python...
Read more >Inserting image into IPython notebook markdown
I found it helpful to just use the notebook insert image - which added the image as an attachment (which is now portable)....
Read more >Documentation Style Guide - GitLab Docs
The GitLab documentation is not localized, but we follow guidelines that help benefit ... check that all documentation PNG images have been compressed:....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was looking at it because it was unassigned. Here’s a start: https://github.com/rchiodo/vscode/commit/8acd26407529bfa338732e5e3664e39723e1d795
Thanks for filing this issue, i’ll look into this and am certain we can get this sorted out. Apologies this causes issues with your workflow.