-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
last edit mark is tampered after ClangFormat #106
Comments
I'm facing this same issue when enabling the option that automatically formats upon leaving insert mode (g:clang_format#auto_format_on_insert_leave). In such cases, I often navigate away and then want to come back to that last edit using "g;", but it instead brings me to the end of the file. In short, it seems like running any of these clang-format commands (automatically or manually) pollutes the vim change list, when I would prefer it didn't. (I'm guessing (pure speculation) that these commands overwrite the entire buffer with one that is equivalent everywhere except where you asked for formatting, which would cause vim to add an entry to its change list pointing at the last line of the file). |
I think we need to use the builtin ":keepjumps" command somehow to achieve what we want. See here: |
I think I figured out how to fix this issue: In this function: vim-clang-format/autoload/clang_format.vim Line 252 in 6b79182
I added the "keepjumps" keyword to two nearby commands that edit the file (as shown below): Before:
After:
This appears to give the desired result in both my scenario and the scenario posted by shreejun. |
Select a line in visual mode and do :ClangFormat. It formats only the selected line as expected. Move around the cursor to other lines, and then press `. in order to jump to the line formatted earlier. It jumps to the end of the file instead.
The text was updated successfully, but these errors were encountered: