remove unwraps

This commit is contained in:
Eli Dowling 2024-02-06 09:23:03 +10:00 committed by Eli Dowling
parent ff43c4bbcb
commit eb53f8d99f

View file

@ -235,11 +235,11 @@ impl AnalyzedDocument {
let is_field_or_module_completion = symbol_prefix.contains('.'); let is_field_or_module_completion = symbol_prefix.contains('.');
if is_field_or_module_completion { if is_field_or_module_completion {
//if the second last second is capitalised we know we are completing a module of an import of a module //if the second last section is capitalised we know we are completing a module of an import of a module eg: My.Module.function
let is_module_completion = symbol_prefix let is_module_completion = symbol_prefix
.split('.') .split('.')
.nth_back(1) .nth_back(1)
.map(|a| a.chars().nth(0).unwrap().is_uppercase()) .and_then(|a| a.chars().nth(0).map(|c| c.is_uppercase()))
.unwrap_or(false); .unwrap_or(false);
if is_module_completion { if is_module_completion {
info!("Getting module dot completion"); info!("Getting module dot completion");
@ -267,7 +267,10 @@ impl AnalyzedDocument {
) )
} }
} else { } else {
let is_module_or_type_completion = symbol_prefix.chars().nth(0).unwrap().is_uppercase(); let is_module_or_type_completion = symbol_prefix
.chars()
.nth(0)
.map_or(false, |c| c.is_uppercase());
if is_module_or_type_completion { if is_module_or_type_completion {
info!("Getting module completion"); info!("Getting module completion");
let completions = get_upper_case_completion_items( let completions = get_upper_case_completion_items(