Skip to content

Parsimonious buffer updates #122

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions autoload/clang_format.vim
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,19 @@ function! clang_format#replace_ranges(ranges, ...) abort
endif

let winview = winsaveview()
let splitted = split(formatted, '\n', 1)

silent! undojoin
if line('$') > len(splitted)
execute len(splitted) .',$delete' '_'
let line_num = 0
for line in split(formatted, '\n', 1)
let line_num += 1
if line != getline(line_num)
call setline(line_num, line)
endif
endfor
if line('$') > line_num
execute (line_num + 1) .',$delete' '_'
endif
call setline(1, splitted)

call winrestview(winview)
call setpos('.', pos_save)
endfunction
Expand Down