Skip to content

Commit d01c79d

Browse files
cant fail
1 parent 1a7cc0f commit d01c79d

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

crates/pgt_completions/src/complete.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ pub struct CompletionParams<'a> {
2323
position = params.position.to_string()
2424
))]
2525
pub fn complete(params: CompletionParams) -> Vec<CompletionItem> {
26-
let sanitized_params = match SanitizedCompletionParams::try_from(params) {
27-
Ok(p) => p,
28-
Err(err) => {
29-
tracing::warn!("Not possible to get completions: {}", err);
30-
return vec![];
31-
}
32-
};
26+
let sanitized_params = SanitizedCompletionParams::from(params);
3327

3428
let ctx = CompletionContext::new(&sanitized_params);
3529

crates/pgt_completions/src/sanitization.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,18 @@ pub fn benchmark_sanitization(params: CompletionParams) -> String {
1616
params.text
1717
}
1818

19-
impl<'larger, 'smaller> TryFrom<CompletionParams<'larger>> for SanitizedCompletionParams<'smaller>
19+
impl<'larger, 'smaller> From<CompletionParams<'larger>> for SanitizedCompletionParams<'smaller>
2020
where
2121
'larger: 'smaller,
2222
{
23-
type Error = String;
24-
25-
fn try_from(params: CompletionParams<'larger>) -> Result<Self, Self::Error> {
23+
fn from(params: CompletionParams<'larger>) -> Self {
2624
if cursor_inbetween_nodes(params.tree, params.position)
2725
|| cursor_prepared_to_write_token_after_last_node(params.tree, params.position)
2826
|| cursor_before_semicolon(params.tree, params.position)
2927
{
30-
Ok(SanitizedCompletionParams::with_adjusted_sql(params))
28+
SanitizedCompletionParams::with_adjusted_sql(params)
3129
} else {
32-
Ok(SanitizedCompletionParams::unadjusted(params))
30+
SanitizedCompletionParams::unadjusted(params)
3331
}
3432
}
3533
}

0 commit comments

Comments
 (0)