File tree Expand file tree Collapse file tree 1 file changed +2
-29
lines changed Expand file tree Collapse file tree 1 file changed +2
-29
lines changed Original file line number Diff line number Diff line change @@ -212,36 +212,9 @@ function! clang_format#replace(line1, line2)
212212
213213 try
214214 let formatted = clang_format#format (a: line1 , a: line2 )
215-
216215 if s: success (formatted)
217- try
218- " Note:
219- " Replace current buffer with workaround not to move
220- " the cursor on undo (issue #8)
221- "
222- " The points are:
223- " - Do not touch the first line.
224- " - Use :put (p, P and :put! is not available).
225- "
226- " To meet above condition:
227- " - Delete all lines except for the first line.
228- " - Put formatted text except for the first line.
229- "
230- let i = stridx (formatted, " \n " )
231- if i == -1 || getline (1 ) !=# formatted[:i - 1 ]
232- throw ' fallback'
233- endif
234-
235- call setreg (' g' , formatted[i + 1 :], ' V' )
236- silent normal ! 2 gg" _dG
237- silent put g
238- catch
239- " Fallback:
240- " The previous way. It lets the cursor move to the first line
241- " on undo.
242- call setreg (' g' , formatted, ' V' )
243- silent keepjumps normal ! ggVG" gp
244- endtry
216+ call setreg (' g' , formatted, ' V' )
217+ silent keepjumps normal ! ggVG" gp
245218 else
246219 call s: error_message (formatted)
247220 endif
You can’t perform that action at this time.
0 commit comments