Skip to content

Commit

Permalink
cleaner conversion of formatting properties
Browse files Browse the repository at this point in the history
  • Loading branch information
farwyler committed Jun 1, 2022
1 parent 644a1f5 commit 563fccf
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,18 +416,10 @@ impl Document {
.language_config()
.and_then(|cfg| cfg.format.as_ref().and_then(|c| c.as_object()))
{
for (key, value) in fmt {
let prop = if let Some(s) = value.as_str() {
lsp::FormattingProperty::String(s.to_owned())
} else if let Some(b) = value.as_bool() {
lsp::FormattingProperty::Bool(b)
} else if let Some(n) = value.as_i64() {
lsp::FormattingProperty::Number(n as i32)
} else {
log::warn!("invalid formatting property type {:?} for {}", value, key);
continue;
};
properties.insert(key.to_owned(), prop);
for (key, value) in fmt.iter() {
if let Ok(prop) = serde_json::from_value(value.clone()) {
properties.insert(key.to_owned(), prop);
}
}
}

Expand Down

0 comments on commit 563fccf

Please sign in to comment.