@@ -186,7 +186,7 @@ function! s:detect_style_file()
186
186
endfunction
187
187
188
188
function ! clang_format#format (line1, line2)
189
- let args = printf ( ' -lines=%d:%d ' , a: line1 , a: line2 )
189
+ let args = " "
190
190
if ! (g: clang_format #detect_style_file && s: detect_style_file ())
191
191
let args .= printf (' -style=%s ' , s: make_style_options ())
192
192
else
@@ -198,7 +198,7 @@ function! clang_format#format(line1, line2)
198
198
endif
199
199
let args .= g: clang_format #extra_args
200
200
let clang_format = printf (' %s %s --' , s: shellescape (g: clang_format #command ), args )
201
- return s: system (clang_format, join (getline (1 , ' $ ' ), " \n " ))
201
+ return s: system (clang_format, join (getline (a: line1 , a: line2 ), " \n " ))
202
202
endfunction
203
203
" }}}
204
204
@@ -216,8 +216,12 @@ function! clang_format#replace(line1, line2)
216
216
try
217
217
let formatted = clang_format#format (a: line1 , a: line2 )
218
218
if s: success (formatted)
219
+ let indent = indent (a: line1 ) / shiftwidth ()
220
+ silent exe a: line1 .' ,' a: line2 .' delete _'
221
+
219
222
call setreg (' g' , formatted, ' V' )
220
- silent keepjumps normal ! ggVG" gp
223
+ silent put ! g
224
+ silent exe " '[,']" .repeat (' >' , indent )
221
225
else
222
226
call s: error_message (formatted)
223
227
endif
0 commit comments