From 0f7cca8dfcee5a1e50bd060c1085828529391a4c Mon Sep 17 00:00:00 2001 From: rhysd Date: Sun, 8 Jan 2017 16:54:31 +0900 Subject: [PATCH] remove first line hack because it doesn't resolve #8 --- autoload/clang_format.vim | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/autoload/clang_format.vim b/autoload/clang_format.vim index 6400892..e950188 100644 --- a/autoload/clang_format.vim +++ b/autoload/clang_format.vim @@ -212,36 +212,9 @@ function! clang_format#replace(line1, line2) try let formatted = clang_format#format(a:line1, a:line2) - if s:success(formatted) - try - " Note: - " Replace current buffer with workaround not to move - " the cursor on undo (issue #8) - " - " The points are: - " - Do not touch the first line. - " - Use :put (p, P and :put! is not available). - " - " To meet above condition: - " - Delete all lines except for the first line. - " - Put formatted text except for the first line. - " - let i = stridx(formatted, "\n") - if i == -1 || getline(1) !=# formatted[:i-1] - throw 'fallback' - endif - - call setreg('g', formatted[i+1:], 'V') - silent normal! 2gg"_dG - silent put g - catch - " Fallback: - " The previous way. It lets the cursor move to the first line - " on undo. - call setreg('g', formatted, 'V') - silent keepjumps normal! ggVG"gp - endtry + call setreg('g', formatted, 'V') + silent keepjumps normal! ggVG"gp else call s:error_message(formatted) endif