xaverh / vscode-clang-format

A Visual Studio Code extension that provides C++, C, Obj-C, Java formatting with the use of clang-format
https://marketplace.visualstudio.com/items?itemName=xaver.clang-format
MIT License
236 stars 76 forks source link

Format on save add garbage to the file #77

Open giellamo opened 5 years ago

giellamo commented 5 years ago

VSCode Version: 1.30.0 OS Version: Ubuntu 18.04 During C++ editing

Steps to Reproduce:

Enable clang-format configure format on save "editor.formatOnSave": true modify multiple files and copy / paste stuff sometimes (much more frequently after code update to 1.30) autoformat on save pastes garbage into the file. Extensions enabled Extensions Added: clang-format v1.8.0 cmake v0.0.17 cmake-tools v1.1.3 code-settings-sync v3.2.4 cpptools v0.20.1 dark-plus-material v1.4.5 doxdocgen v0.4.1 Doxygen v1.0.0 flatbuffers v0.1.0 gitlens v9.2.0 hg v1.2.3 linkerscript v1.0.0 material-icon-theme v3.6.1 meson v1.1.1 python v2018.12.0 QML v1.0.0 vsc-material-theme v2.6.2 vsc-qml-snippets v0.0.2

datoml commented 5 years ago

I have the same problems. Are there any workarounds to solve this?

ghost commented 5 years ago

In my setup I discovered that the problem was the symbolic link in the path.

Without any I've never experienced other problems.

datoml commented 5 years ago

In my setup I discovered that the problem was the symbolic link in the path.

Without any I've never experienced other problems.

I forgot to mention that I am on Windows. :)

ghost commented 5 years ago

Maybe a Junction :D

killkrt commented 5 years ago

Same issue here on Arch Linux (64bit). No symbolic links in use, but I am working on a NTFS filesystem mounted using FuseNTFS (not sure that it is relevant).

I've noticed that usually happens when I switch from header/source (.h <-> .cpp) and VS Code reopens, by mistake, the file (that was already opened) in a new tab (specifying the full path in the tab name). It also happen when MS-VScode.cpptools plug-in struggles to parse the code (when I use a lot of lambda expression or structured binding), so I guess that is someway related to the same thing, but I cannot understand why it pastes random garbage across my file!

clang-version: 8.0.1 VS Code: 1.37.1 Plug-in version: 1.9.0