Skip to content

Commit

Permalink
refactor: use async block
Browse files Browse the repository at this point in the history
too many `Ok(None)`s!
  • Loading branch information
sh-cho committed Oct 19, 2024
1 parent e9804cf commit 254e0e7
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions fluent-bit-language-server/src/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,24 +327,22 @@ impl LanguageServer for Backend {
row: position.line as usize,
column: position.character as usize,
};
let Some(key) = self.get_key_at_point(&text_document.uri, &point).await else {
return Ok(None);
};
let Some(section_type) = self
.get_section_type_at_point(&text_document.uri, &point)
.await
else {
return Ok(None);
};

let Some(param_info) = get_hover_info(&section_type, &key) else {
return Ok(None);
};
let hover = async {
let key = self.get_key_at_point(&text_document.uri, &point).await?;
let section_type = self
.get_section_type_at_point(&text_document.uri, &point)
.await?;
let param_info = get_hover_info(&section_type, &key)?;

Some(Hover {
contents: HoverContents::Markup(param_info.into()),
range: None,
})
}
.await;

Ok(Some(Hover {
contents: HoverContents::Markup(param_info.into()),
range: None,
}))
Ok(hover)
}

// TODO: Supply snippet only when there's no "Name" entry
Expand Down

0 comments on commit 254e0e7

Please sign in to comment.