Skip to content

Commit

Permalink
do not throw exception not to prevent saving file on formatting (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Feb 29, 2020
1 parent 20e9562 commit 31db50d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion autoload/crystal_lang.vim
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,15 @@ function! crystal_lang#format(option_str, ...) abort
endif

let before = join(getline(1, '$'), "\n")
let formatted = crystal_lang#format_string(before, a:option_str)
try
let formatted = crystal_lang#format_string(before, a:option_str)
catch /^vim-crystal: /
echohl ErrorMsg
echomsg v:exception . ': Your code was not formatted. Exception was thrown at ' . v:throwpoint
echohl None
return
endtry

if !on_save
let after = substitute(formatted, '\n$', '', '')
if before ==# after
Expand Down

0 comments on commit 31db50d

Please sign in to comment.