Skip to content

Commit 8ff1660

Browse files
committed
prefer early return
1 parent 77be224 commit 8ff1660

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

autoload/clang_format.vim

+12-12
Original file line numberDiff line numberDiff line change
@@ -230,21 +230,21 @@ function! clang_format#replace(line1, line2, ...) abort
230230

231231
let pos_save = a:0 >= 1 ? a:1 : getpos('.')
232232
let formatted = clang_format#format(a:line1, a:line2)
233-
if s:success(formatted)
234-
let winview = winsaveview()
235-
let splitted = split(formatted, '\n')
236-
237-
silent! undojoin
238-
if line('$') > len(splitted)
239-
execute len(splitted) .',$delete' '_'
240-
endif
241-
call setline(1, splitted)
242-
call winrestview(winview)
243-
call setpos('.', pos_save)
244-
else
233+
if !s:success(formatted)
245234
call s:error_message(formatted)
235+
return
246236
endif
247237

238+
let winview = winsaveview()
239+
let splitted = split(formatted, '\n')
240+
241+
silent! undojoin
242+
if line('$') > len(splitted)
243+
execute len(splitted) .',$delete' '_'
244+
endif
245+
call setline(1, splitted)
246+
call winrestview(winview)
247+
call setpos('.', pos_save)
248248
endfunction
249249
" }}}
250250

0 commit comments

Comments
 (0)