Merge pull request #2355 from topecongiro/hide-parse-error-format-snippet

Hide parse error in format_snippet()
This commit is contained in:
Nick Cameron 2018-01-12 17:31:43 +13:00 committed by GitHub
commit a7d1d1da0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -540,6 +540,7 @@ pub fn format_snippet(snippet: &str, config: &Config) -> Option<String> {
let input = Input::Text(snippet.into());
let mut config = config.clone();
config.set().write_mode(config::WriteMode::Plain);
config.set().hide_parse_errors(true);
match format_input(input, &config, Some(&mut out)) {
// `format_input()` returns an empty string on parsing error.
Ok(..) if out.is_empty() && !snippet.is_empty() => None,