vim-clang-format
vim-clang-format copied to clipboard
format of source code removes all marks
ClangFormat of the entire source code removes all marks.
steps to reproduce in normal mode:
:ClangFormat //format to make sure the next call does nothing
mm //set the mark m
:marks //you see the mark m now
:ClangFormat //does nothing now
:marks //now the mark is gone
Hi @krux02.
Great catch! I couldn't notice that because I don't use marks. I'll reproduce the bug and consider the way to avoid.
I don't know, how clang format works at the moment, but I think it just replaces the entire buffer with the output of clang-format. I think a simple way to implement it, that has the least amount of side effects, is to make a diff with the current buffer, and the output of clang-format, and then apply the diff on the buffer. This way you as the user don't need to carefully select the text for clang-format, and still only a tiny portion of the buffer gets changed.
EDIT: it seems like clang-format already has a -output-replacements-xml argument, where you just get the changes.
EDIT2: I tested clang-format.py, and it works better. unchanged files still keep their marks, but changed lines loose them. So at the moment I am back to that tool.
In case you want to know. if you have autoread set, your buffer is written and an external program does changes to the file, vim reloads the file with properly migrating the marks.