microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.21k stars 29.29k forks source link

"Format Notebook" damages LaTeX in Markdown cells #193023

Open welldone43 opened 1 year ago

welldone43 commented 1 year ago

Type: Bug

For reproduction:

The equation changes during the autoformating. There are also other kinds of changes in the equation, but that should help to find the bug. I use the black formatter.

VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:18:39.991Z) OS version: Linux x64 5.15.0-83-generic Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (6 x 2591)| |GPU Status|2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off| |Load (avg)|1, 1, 1| |Memory (System)|23.02GB (15.96GB free)| |Process Argv|. --crash-reporter-id 574f540c-3290-4534-a6a9-6d182d854876| |Screen Reader|no| |VM|100%| |DESKTOP_SESSION|ubuntu| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|ubuntu| |XDG_SESSION_TYPE|x11|
Extensions (39) Extension|Author (truncated)|Version ---|---|--- vscode-django|bat|1.11.0 markdown-mermaid|bie|1.19.0 markdown-preview-github-styles|bie|2.0.2 my-nbpreviewer|col|1.2.2 vscode-markdownlint|Dav|0.51.0 python-environment-manager|don|1.0.4 python-extension-pack|don|1.7.0 gitlens|eam|14.3.0 prettier-vscode|esb|10.1.0 myst-highlight|Exe|0.11.0 gitlab-workflow|Git|3.77.0 vscode-h5web|h5w|0.0.10 nbpreviewer|jit|1.2.2 vsc-python-indent|Kev|1.18.0 black-formatter|ms-|2023.4.1 python|ms-|2023.15.12301911 vscode-pylance|ms-|2023.9.10 jupyter|ms-|2023.7.1002162226 jupyter-keymap|ms-|1.1.2 jupyter-renderers|ms-|1.0.17 vscode-jupyter-cell-tags|ms-|0.1.8 vscode-jupyter-powertoys|ms-|0.0.8 vscode-jupyter-slideshow|ms-|0.1.5 remote-containers|ms-|0.309.0 remote-ssh|ms-|0.102.0 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.81.3 vscode-remote-extensionpack|ms-|0.24.0 remote-explorer|ms-|0.4.1 remote-server|ms-|1.4.3 autodocstring|njp|0.6.1 jupyter-notebook-vscode|sam|0.0.2 markdown-preview-enhanced|shd|0.7.3 code-spell-checker|str|3.0.1 intellicode-api-usage-examples|Vis|0.2.8 vscodeintellicode|Vis|1.2.30 jinja|who|0.0.8 markdown-pdf|yza|1.5.0 markdown-all-in-one|yzh|3.5.1
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 py29gd2263cf:30792227 vsclangdf:30486550 c4g48928:30535728 dsvsc012cf:30540253 pynewext54:30695312 azure-dev_surveyone:30548225 vscccc:30803845 3biah626:30602489 f6dab269:30613381 a9j8j154:30646983 showlangstatbar:30737416 03d35959:30757346 57b77579:30736110 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxpt:30805730 pythonnoceb:30805159 dsvsc013:30795093 dsvsc014:30804076 diffeditorv2:30821572 dsvsc015:30829745 ```
vscodenpa commented 1 year ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.82.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

welldone43 commented 1 year ago

Thanks for reminding me to update VSCode before reporting a bug. I updated VSCode and the extensions, as documented in the summary below. The bug remains the same.

VS Code version: Code 1.82.1 (6509174151d557a81c9d0b5f8a5a1e9274db5585, 2023-09-08T08:41:36.199Z) OS version: Linux x64 5.15.0-83-generic Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (6 x 2591)| |GPU Status|2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off| |Load (avg)|3, 2, 1| |Memory (System)|23.02GB (20.28GB free)| |Process Argv|. --crash-reporter-id 574f540c-3290-4534-a6a9-6d182d854876| |Screen Reader|no| |VM|100%| |DESKTOP_SESSION|ubuntu| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|ubuntu| |XDG_SESSION_TYPE|x11|
Extensions (39) Extension|Author (truncated)|Version ---|---|--- vscode-django|bat|1.11.0 markdown-mermaid|bie|1.19.0 markdown-preview-github-styles|bie|2.0.2 my-nbpreviewer|col|1.2.2 vscode-markdownlint|Dav|0.51.0 python-environment-manager|don|1.2.2 python-extension-pack|don|1.7.0 gitlens|eam|14.3.0 prettier-vscode|esb|10.1.0 myst-highlight|Exe|0.11.0 gitlab-workflow|Git|3.77.0 vscode-h5web|h5w|0.0.10 nbpreviewer|jit|1.2.2 vsc-python-indent|Kev|1.18.0 black-formatter|ms-|2023.4.1 python|ms-|2023.17.12571005 vscode-pylance|ms-|2023.9.10 jupyter|ms-|2023.8.1002501831 jupyter-keymap|ms-|1.1.2 jupyter-renderers|ms-|1.0.17 vscode-jupyter-cell-tags|ms-|0.1.8 vscode-jupyter-powertoys|ms-|0.0.8 vscode-jupyter-slideshow|ms-|0.1.5 remote-containers|ms-|0.309.0 remote-ssh|ms-|0.106.4 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.81.3 vscode-remote-extensionpack|ms-|0.24.0 remote-explorer|ms-|0.4.1 remote-server|ms-|1.4.3 autodocstring|njp|0.6.1 jupyter-notebook-vscode|sam|0.0.2 markdown-preview-enhanced|shd|0.7.6 code-spell-checker|str|3.0.1 intellicode-api-usage-examples|Vis|0.2.8 vscodeintellicode|Vis|1.2.30 jinja|who|0.0.8 markdown-pdf|yza|1.5.0 markdown-all-in-one|yzh|3.5.1
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 py29gd2263cf:30792227 vsclangdf:30486550 c4g48928:30535728 dsvsc012cf:30540253 pynewext54:30695312 azure-dev_surveyone:30548225 vscccc:30803845 3biah626:30602489 f6dab269:30613381 a9j8j154:30646983 showlangstatbar:30737416 962ge761:30835153 03d35959:30757346 57b77579:30736110 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxpt:30805730 pythonnoceb:30805159 dsvsc013:30795093 dsvsc014:30804076 diffeditorv2:30821572 dsvsc015:30829745 ```
welldone43 commented 1 year ago

Please find some screenshots to better understand the issue: 1) before formatting grafik

2) running "Format Notebook" grafik

3) after formatting (note the added dash in front of _1 (it takes a few seconds to update the preview) grafik

Note: the impact on more complex equations is more severe and this is just a minimum example