Format let-else statements

This commit is contained in:
Max Brunsfeld 2023-08-25 10:11:32 -07:00
parent 732af201dc
commit 404f76739c
28 changed files with 210 additions and 109 deletions

View File

@ -1128,7 +1128,9 @@ impl Conversation {
stream: true,
};
let Some(api_key) = self.api_key.borrow().clone() else { continue };
let Some(api_key) = self.api_key.borrow().clone() else {
continue;
};
let stream = stream_completion(api_key, cx.background().clone(), request);
let assistant_message = self
.insert_message_after(
@ -1484,7 +1486,9 @@ impl Conversation {
}) {
current_message = messages.next();
}
let Some(message) = current_message.as_ref() else { break };
let Some(message) = current_message.as_ref() else {
break;
};
// Skip offsets that are in the same message.
while offsets.peek().map_or(false, |offset| {
@ -1921,7 +1925,10 @@ impl ConversationEditor {
let Some(panel) = workspace.panel::<AssistantPanel>(cx) else {
return;
};
let Some(editor) = workspace.active_item(cx).and_then(|item| item.act_as::<Editor>(cx)) else {
let Some(editor) = workspace
.active_item(cx)
.and_then(|item| item.act_as::<Editor>(cx))
else {
return;
};

View File

@ -644,7 +644,9 @@ impl Room {
if let Some(participants) = remote_participants.log_err() {
for (participant, user) in room.participants.into_iter().zip(participants) {
let Some(peer_id) = participant.peer_id else { continue };
let Some(peer_id) = participant.peer_id else {
continue;
};
this.participant_user_ids.insert(participant.user_id);
let old_projects = this

View File

@ -249,7 +249,9 @@ impl Database {
let mut tx = Arc::new(Some(tx));
let result = f(TransactionHandle(tx.clone())).await;
let Some(tx) = Arc::get_mut(&mut tx).and_then(|tx| tx.take()) else {
return Err(anyhow!("couldn't complete transaction because it's still in use"))?;
return Err(anyhow!(
"couldn't complete transaction because it's still in use"
))?;
};
Ok((tx, result))

View File

@ -465,9 +465,9 @@ impl Database {
let mut rejoined_projects = Vec::new();
for rejoined_project in &rejoin_room.rejoined_projects {
let project_id = ProjectId::from_proto(rejoined_project.id);
let Some(project) = project::Entity::find_by_id(project_id)
.one(&*tx)
.await? else { continue };
let Some(project) = project::Entity::find_by_id(project_id).one(&*tx).await? else {
continue;
};
let mut worktrees = Vec::new();
let db_worktrees = project.find_related(worktree::Entity).all(&*tx).await?;

View File

@ -121,7 +121,9 @@ async fn test_random_collaboration(
let mut operation_channels = Vec::new();
loop {
let Some((next_operation, applied)) = plan.lock().next_server_operation(&clients) else { break };
let Some((next_operation, applied)) = plan.lock().next_server_operation(&clients) else {
break;
};
applied.store(true, SeqCst);
let did_apply = apply_server_operation(
deterministic.clone(),
@ -224,7 +226,9 @@ async fn apply_server_operation(
let client_ix = clients
.iter()
.position(|(client, cx)| client.current_user_id(cx) == removed_user_id);
let Some(client_ix) = client_ix else { return false };
let Some(client_ix) = client_ix else {
return false;
};
let user_connection_ids = server
.connection_pool
.lock()
@ -1591,10 +1595,11 @@ impl TestPlan {
81.. => match self.rng.gen_range(0..100_u32) {
// Add a worktree to a local project
0..=50 => {
let Some(project) = client
.local_projects()
.choose(&mut self.rng)
.cloned() else { continue };
let Some(project) =
client.local_projects().choose(&mut self.rng).cloned()
else {
continue;
};
let project_root_name = root_name_for_project(&project, cx);
let mut paths = client.fs().paths(false);
paths.remove(0);
@ -1611,7 +1616,9 @@ impl TestPlan {
// Add an entry to a worktree
_ => {
let Some(project) = choose_random_project(client, &mut self.rng) else { continue };
let Some(project) = choose_random_project(client, &mut self.rng) else {
continue;
};
let project_root_name = root_name_for_project(&project, cx);
let is_local = project.read_with(cx, |project, _| project.is_local());
let worktree = project.read_with(cx, |project, cx| {
@ -1645,7 +1652,9 @@ impl TestPlan {
// Query and mutate buffers
60..=90 => {
let Some(project) = choose_random_project(client, &mut self.rng) else { continue };
let Some(project) = choose_random_project(client, &mut self.rng) else {
continue;
};
let project_root_name = root_name_for_project(&project, cx);
let is_local = project.read_with(cx, |project, _| project.is_local());
@ -1656,7 +1665,10 @@ impl TestPlan {
.buffers_for_project(&project)
.iter()
.choose(&mut self.rng)
.cloned() else { continue };
.cloned()
else {
continue;
};
let full_path = buffer
.read_with(cx, |buffer, cx| buffer.file().unwrap().full_path(cx));
@ -2026,7 +2038,10 @@ async fn simulate_client(
client.app_state.languages.add(Arc::new(language));
while let Some(batch_id) = operation_rx.next().await {
let Some((operation, applied)) = plan.lock().next_client_operation(&client, batch_id, &cx) else { break };
let Some((operation, applied)) = plan.lock().next_client_operation(&client, batch_id, &cx)
else {
break;
};
applied.store(true, SeqCst);
match apply_client_operation(&client, operation, &mut cx).await {
Ok(()) => {}

View File

@ -272,8 +272,12 @@ impl FollowableItem for ChannelView {
state: &mut Option<proto::view::Variant>,
cx: &mut AppContext,
) -> Option<gpui::Task<anyhow::Result<ViewHandle<Self>>>> {
let Some(proto::view::Variant::ChannelView(_)) = state else { return None };
let Some(proto::view::Variant::ChannelView(state)) = state.take() else { unreachable!() };
let Some(proto::view::Variant::ChannelView(_)) = state else {
return None;
};
let Some(proto::view::Variant::ChannelView(state)) = state.take() else {
unreachable!()
};
let open = ChannelView::open(state.channel_id, pane, workspace, cx);

View File

@ -152,12 +152,9 @@ impl View for ChannelModal {
let theme = &theme::current(cx).collab_panel.tabbed_modal;
let mode = self.picker.read(cx).delegate().mode;
let Some(channel) = self
.channel_store
.read(cx)
.channel_for_id(self.channel_id) else {
return Empty::new().into_any()
};
let Some(channel) = self.channel_store.read(cx).channel_for_id(self.channel_id) else {
return Empty::new().into_any();
};
enum InviteMembers {}
enum ManageMembers {}

View File

@ -6243,7 +6243,9 @@ impl Editor {
) {
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
s.move_offsets_with(|snapshot, selection| {
let Some(enclosing_bracket_ranges) = snapshot.enclosing_bracket_ranges(selection.start..selection.end) else {
let Some(enclosing_bracket_ranges) =
snapshot.enclosing_bracket_ranges(selection.start..selection.end)
else {
return;
};
@ -6255,7 +6257,8 @@ impl Editor {
let close = close.to_inclusive();
let length = close.end() - open.start;
let inside = selection.start >= open.end && selection.end <= *close.start();
let in_bracket_range = open.to_inclusive().contains(&selection.head()) || close.contains(&selection.head());
let in_bracket_range = open.to_inclusive().contains(&selection.head())
|| close.contains(&selection.head());
// If best is next to a bracket and current isn't, skip
if !in_bracket_range && best_in_bracket_range {
@ -6270,19 +6273,21 @@ impl Editor {
best_length = length;
best_inside = inside;
best_in_bracket_range = in_bracket_range;
best_destination = Some(if close.contains(&selection.start) && close.contains(&selection.end) {
if inside {
open.end
best_destination = Some(
if close.contains(&selection.start) && close.contains(&selection.end) {
if inside {
open.end
} else {
open.start
}
} else {
open.start
}
} else {
if inside {
*close.start()
} else {
*close.end()
}
});
if inside {
*close.start()
} else {
*close.end()
}
},
);
}
if let Some(destination) = best_destination {
@ -6526,7 +6531,9 @@ impl Editor {
split: bool,
cx: &mut ViewContext<Self>,
) {
let Some(workspace) = self.workspace(cx) else { return };
let Some(workspace) = self.workspace(cx) else {
return;
};
let buffer = self.buffer.read(cx);
let head = self.selections.newest::<usize>(cx).head();
let (buffer, head) = if let Some(text_anchor) = buffer.text_anchor_for_position(head, cx) {
@ -6557,7 +6564,9 @@ impl Editor {
split: bool,
cx: &mut ViewContext<Editor>,
) {
let Some(workspace) = self.workspace(cx) else { return };
let Some(workspace) = self.workspace(cx) else {
return;
};
let pane = workspace.read(cx).active_pane().clone();
// If there is one definition, just open it directly
if definitions.len() == 1 {
@ -7639,10 +7648,9 @@ impl Editor {
let search_range = display_snapshot.anchor_to_inlay_offset(search_range.start)
..display_snapshot.anchor_to_inlay_offset(search_range.end);
let mut results = Vec::new();
let Some((_, ranges)) = self.background_highlights
.get(&TypeId::of::<T>()) else {
return vec![];
};
let Some((_, ranges)) = self.background_highlights.get(&TypeId::of::<T>()) else {
return vec![];
};
let start_ix = match ranges.binary_search_by(|probe| {
let cmp = document_to_inlay_range(probe, display_snapshot)
@ -7993,9 +8001,7 @@ impl Editor {
suggestion_accepted: bool,
cx: &AppContext,
) {
let Some(project) = &self.project else {
return
};
let Some(project) = &self.project else { return };
// If None, we are either getting suggestions in a new, unsaved file, or in a file without an extension
let file_extension = self
@ -8024,9 +8030,7 @@ impl Editor {
file_extension: Option<String>,
cx: &AppContext,
) {
let Some(project) = &self.project else {
return
};
let Some(project) = &self.project else { return };
// If None, we are in a file without an extension
let file = self
@ -8127,7 +8131,9 @@ impl Editor {
}
}
let Some(lines) = serde_json::to_string_pretty(&lines).log_err() else { return; };
let Some(lines) = serde_json::to_string_pretty(&lines).log_err() else {
return;
};
cx.write_to_clipboard(ClipboardItem::new(lines));
}

View File

@ -341,7 +341,10 @@ impl InlayHintCache {
shown_excerpt_hints_to_remove.retain(|(shown_anchor, shown_hint_id)| {
let Some(buffer) = shown_anchor
.buffer_id
.and_then(|buffer_id| multi_buffer.buffer(buffer_id)) else { return false };
.and_then(|buffer_id| multi_buffer.buffer(buffer_id))
else {
return false;
};
let buffer_snapshot = buffer.read(cx).snapshot();
loop {
match excerpt_cache.peek() {
@ -554,7 +557,10 @@ fn spawn_new_update_tasks(
cx,
),
)
}) else { return; };
})
else {
return;
};
let query = ExcerptQuery {
buffer_id,
excerpt_id,

View File

@ -55,8 +55,12 @@ impl FollowableItem for Editor {
cx: &mut AppContext,
) -> Option<Task<Result<ViewHandle<Self>>>> {
let project = workspace.read(cx).project().to_owned();
let Some(proto::view::Variant::Editor(_)) = state else { return None };
let Some(proto::view::Variant::Editor(state)) = state.take() else { unreachable!() };
let Some(proto::view::Variant::Editor(_)) = state else {
return None;
};
let Some(proto::view::Variant::Editor(state)) = state.take() else {
unreachable!()
};
let client = project.read(cx).client();
let replica_id = project.read(cx).replica_id();
@ -341,10 +345,16 @@ async fn update_editor_from_message(
let mut insertions = message.inserted_excerpts.into_iter().peekable();
while let Some(insertion) = insertions.next() {
let Some(excerpt) = insertion.excerpt else { continue };
let Some(previous_excerpt_id) = insertion.previous_excerpt_id else { continue };
let Some(excerpt) = insertion.excerpt else {
continue;
};
let Some(previous_excerpt_id) = insertion.previous_excerpt_id else {
continue;
};
let buffer_id = excerpt.buffer_id;
let Some(buffer) = project.read(cx).buffer_for_id(buffer_id, cx) else { continue };
let Some(buffer) = project.read(cx).buffer_for_id(buffer_id, cx) else {
continue;
};
let adjacent_excerpts = iter::from_fn(|| {
let insertion = insertions.peek()?;

View File

@ -2756,7 +2756,9 @@ impl MultiBufferSnapshot {
// Get the ranges of the innermost pair of brackets.
let mut result: Option<(Range<usize>, Range<usize>)> = None;
let Some(enclosing_bracket_ranges) = self.enclosing_bracket_ranges(range.clone()) else { return None; };
let Some(enclosing_bracket_ranges) = self.enclosing_bracket_ranges(range.clone()) else {
return None;
};
for (open, close) in enclosing_bracket_ranges {
let len = close.end - open.start;

View File

@ -67,7 +67,9 @@ impl KeymapContextPredicate {
}
pub fn eval(&self, contexts: &[KeymapContext]) -> bool {
let Some(context) = contexts.first() else { return false };
let Some(context) = contexts.first() else {
return false;
};
match self {
Self::Identifier(name) => (&context.set).contains(name.as_str()),
Self::Equal(left, right) => context

View File

@ -2484,7 +2484,9 @@ impl BufferSnapshot {
matches.advance();
let Some((open, close)) = open.zip(close) else { continue };
let Some((open, close)) = open.zip(close) else {
continue;
};
let bracket_range = open.start..=close.end;
if !bracket_range.overlaps(&range) {

View File

@ -310,7 +310,9 @@ impl SyntaxSnapshot {
// Ignore edits that end before the start of this layer, and don't consider them
// for any subsequent layers at this same depth.
loop {
let Some((_, edit_range)) = edits.get(first_edit_ix_for_depth) else { continue 'outer };
let Some((_, edit_range)) = edits.get(first_edit_ix_for_depth) else {
continue 'outer;
};
if edit_range.end.cmp(&layer.range.start, text).is_le() {
first_edit_ix_for_depth += 1;
} else {
@ -391,7 +393,9 @@ impl SyntaxSnapshot {
.filter::<_, ()>(|summary| summary.contains_unknown_injections);
cursor.next(text);
while let Some(layer) = cursor.item() {
let SyntaxLayerContent::Pending { language_name } = &layer.content else { unreachable!() };
let SyntaxLayerContent::Pending { language_name } = &layer.content else {
unreachable!()
};
if registry
.language_for_name_or_extension(language_name)
.now_or_never()
@ -533,7 +537,9 @@ impl SyntaxSnapshot {
let content = match step.language {
ParseStepLanguage::Loaded { language } => {
let Some(grammar) = language.grammar() else { continue };
let Some(grammar) = language.grammar() else {
continue;
};
let tree;
let changed_ranges;

View File

@ -932,8 +932,12 @@ fn check_interpolation(
.zip(new_syntax_map.layers.iter())
{
assert_eq!(old_layer.range, new_layer.range);
let Some(old_tree) = old_layer.content.tree() else { continue };
let Some(new_tree) = new_layer.content.tree() else { continue };
let Some(old_tree) = old_layer.content.tree() else {
continue;
};
let Some(new_tree) = new_layer.content.tree() else {
continue;
};
let old_start_byte = old_layer.range.start.to_offset(old_buffer);
let new_start_byte = new_layer.range.start.to_offset(new_buffer);
let old_start_point = old_layer.range.start.to_point(old_buffer).to_ts_point();

View File

@ -549,7 +549,9 @@ impl View for LspLogToolbarItemView {
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
let theme = theme::current(cx).clone();
let Some(log_view) = self.log_view.as_ref() else { return Empty::new().into_any() };
let Some(log_view) = self.log_view.as_ref() else {
return Empty::new().into_any();
};
let log_view = log_view.read(cx);
let menu_rows = log_view.menu_items(cx).unwrap_or_default();

View File

@ -1655,7 +1655,11 @@ impl LspCommand for OnTypeFormatting {
type ProtoRequest = proto::OnTypeFormatting;
fn check_capabilities(&self, server_capabilities: &lsp::ServerCapabilities) -> bool {
let Some(on_type_formatting_options) = &server_capabilities.document_on_type_formatting_provider else { return false };
let Some(on_type_formatting_options) =
&server_capabilities.document_on_type_formatting_provider
else {
return false;
};
on_type_formatting_options
.first_trigger_character
.contains(&self.trigger)
@ -1769,7 +1773,9 @@ impl LspCommand for OnTypeFormatting {
_: ModelHandle<Buffer>,
_: AsyncAppContext,
) -> Result<Option<Transaction>> {
let Some(transaction) = message.transaction else { return Ok(None) };
let Some(transaction) = message.transaction else {
return Ok(None);
};
Ok(Some(language::proto::deserialize_transaction(transaction)?))
}
@ -2238,7 +2244,9 @@ impl LspCommand for InlayHints {
type ProtoRequest = proto::InlayHints;
fn check_capabilities(&self, server_capabilities: &lsp::ServerCapabilities) -> bool {
let Some(inlay_hint_provider) = &server_capabilities.inlay_hint_provider else { return false };
let Some(inlay_hint_provider) = &server_capabilities.inlay_hint_provider else {
return false;
};
match inlay_hint_provider {
lsp::OneOf::Left(enabled) => *enabled,
lsp::OneOf::Right(inlay_hint_capabilities) => match inlay_hint_capabilities {

View File

@ -2317,9 +2317,10 @@ impl BackgroundScannerState {
for changed_path in changed_paths {
let Some(dot_git_dir) = changed_path
.ancestors()
.find(|ancestor| ancestor.file_name() == Some(&*DOT_GIT)) else {
continue;
};
.find(|ancestor| ancestor.file_name() == Some(&*DOT_GIT))
else {
continue;
};
// Avoid processing the same repository multiple times, if multiple paths
// within it have changed.
@ -2348,7 +2349,10 @@ impl BackgroundScannerState {
let Some(work_dir) = self
.snapshot
.entry_for_id(entry_id)
.map(|entry| RepositoryWorkDirectory(entry.path.clone())) else { continue };
.map(|entry| RepositoryWorkDirectory(entry.path.clone()))
else {
continue;
};
log::info!("reload git repository {:?}", dot_git_dir);
let repository = repository.repo_ptr.lock();

View File

@ -40,7 +40,9 @@ impl View for QuickActionBar {
}
fn render(&mut self, cx: &mut gpui::ViewContext<'_, '_, Self>) -> gpui::AnyElement<Self> {
let Some(editor) = self.active_editor() else { return Empty::new().into_any(); };
let Some(editor) = self.active_editor() else {
return Empty::new().into_any();
};
let inlay_hints_enabled = editor.read(cx).inlay_hints_enabled();
let mut bar = Flex::row().with_child(render_quick_action_bar_button(

View File

@ -885,7 +885,9 @@ impl ProjectSearchView {
if !dir_entry.is_dir() {
return;
}
let Some(filter_str) = dir_entry.path.to_str() else { return; };
let Some(filter_str) = dir_entry.path.to_str() else {
return;
};
let model = cx.add_model(|cx| ProjectSearch::new(workspace.project().clone(), cx));
let search = cx.add_view(|cx| ProjectSearchView::new(model, cx));

View File

@ -57,7 +57,9 @@ pub fn init(
cx.subscribe_global::<WorkspaceCreated, _>({
move |event, cx| {
let Some(semantic_index) = SemanticIndex::global(cx) else { return; };
let Some(semantic_index) = SemanticIndex::global(cx) else {
return;
};
let workspace = &event.0;
if let Some(workspace) = workspace.upgrade(cx) {
let project = workspace.read(cx).project().clone();

View File

@ -63,20 +63,23 @@ impl KeymapFile {
// string. But `RawValue` currently does not work inside of an untagged enum.
match action {
Value::Array(items) => {
let Ok([name, data]): Result<[serde_json::Value; 2], _> = items.try_into() else {
let Ok([name, data]): Result<[serde_json::Value; 2], _> =
items.try_into()
else {
return Some(Err(anyhow!("Expected array of length 2")));
};
let serde_json::Value::String(name) = name else {
return Some(Err(anyhow!("Expected first item in array to be a string.")))
return Some(Err(anyhow!(
"Expected first item in array to be a string."
)));
};
cx.deserialize_action(
&name,
Some(data),
)
},
cx.deserialize_action(&name, Some(data))
}
Value::String(name) => cx.deserialize_action(&name, None),
Value::Null => Ok(no_action()),
_ => return Some(Err(anyhow!("Expected two-element array, got {action:?}"))),
_ => {
return Some(Err(anyhow!("Expected two-element array, got {action:?}")))
}
}
.with_context(|| {
format!(

View File

@ -107,20 +107,15 @@ impl PickerDelegate for BranchListDelegate {
let delegate = view.delegate();
let project = delegate.workspace.read(cx).project().read(&cx);
let Some(worktree) = project
.visible_worktrees(cx)
.next()
else {
let Some(worktree) = project.visible_worktrees(cx).next() else {
bail!("Cannot update branch list as there are no visible worktrees")
};
let mut cwd = worktree .read(cx)
.abs_path()
.to_path_buf();
let mut cwd = worktree.read(cx).abs_path().to_path_buf();
cwd.push(".git");
let Some(repo) = project.fs().open_repo(&cwd) else {bail!("Project does not have associated git repository.")};
let mut branches = repo
.lock()
.branches()?;
let Some(repo) = project.fs().open_repo(&cwd) else {
bail!("Project does not have associated git repository.")
};
let mut branches = repo.lock().branches()?;
const RECENT_BRANCHES_COUNT: usize = 10;
if query.is_empty() && branches.len() > RECENT_BRANCHES_COUNT {
// Truncate list of recent branches
@ -142,8 +137,13 @@ impl PickerDelegate for BranchListDelegate {
})
.collect::<Vec<_>>())
})
.log_err() else { return; };
let Some(candidates) = candidates.log_err() else {return;};
.log_err()
else {
return;
};
let Some(candidates) = candidates.log_err() else {
return;
};
let matches = if query.is_empty() {
candidates
.into_iter()
@ -184,7 +184,11 @@ impl PickerDelegate for BranchListDelegate {
fn confirm(&mut self, _: bool, cx: &mut ViewContext<Picker<Self>>) {
let current_pick = self.selected_index();
let Some(current_pick) = self.matches.get(current_pick).map(|pick| pick.string.clone()) else {
let Some(current_pick) = self
.matches
.get(current_pick)
.map(|pick| pick.string.clone())
else {
return;
};
cx.spawn(|picker, mut cx| async move {

View File

@ -33,7 +33,7 @@ fn paste(_: &mut Workspace, action: &Paste, cx: &mut ViewContext<Workspace>) {
editor.set_clip_at_line_ends(false, cx);
let Some(item) = cx.read_from_clipboard() else {
return
return;
};
let clipboard_text = Cow::Borrowed(item.text());
if clipboard_text.is_empty() {

View File

@ -77,7 +77,10 @@ pub fn visual_motion(motion: Motion, times: Option<usize>, cx: &mut WindowContex
}
let Some((new_head, goal)) =
motion.move_point(map, current_head, selection.goal, times) else { return };
motion.move_point(map, current_head, selection.goal, times)
else {
return;
};
selection.set_head(new_head, goal);
@ -132,7 +135,7 @@ pub fn visual_block_motion(
}
let Some((new_head, _)) = move_selection(&map, head, goal) else {
return
return;
};
head = new_head;

View File

@ -742,8 +742,8 @@ mod element {
while proposed_current_pixel_change.abs() > 0. {
let Some(current_ix) = successors.next() else {
break;
};
break;
};
let next_target_size = f32::max(
size(current_ix + 1, flexes.as_slice()) - proposed_current_pixel_change,

View File

@ -2314,8 +2314,12 @@ impl Workspace {
item_id_to_move: usize,
cx: &mut ViewContext<Self>,
) {
let Some(pane_to_split) = pane_to_split.upgrade(cx) else { return; };
let Some(from) = from.upgrade(cx) else { return; };
let Some(pane_to_split) = pane_to_split.upgrade(cx) else {
return;
};
let Some(from) = from.upgrade(cx) else {
return;
};
let new_pane = self.add_pane(cx);
self.move_item(from.clone(), new_pane.clone(), item_id_to_move, 0, cx);

View File

@ -89,7 +89,9 @@ impl LspAdapter for PythonLspAdapter {
// to allow our own fuzzy score to be used to break ties.
//
// see https://github.com/microsoft/pyright/blob/95ef4e103b9b2f129c9320427e51b73ea7cf78bd/packages/pyright-internal/src/languageService/completionProvider.ts#LL2873
let Some(sort_text) = &mut item.sort_text else { return };
let Some(sort_text) = &mut item.sort_text else {
return;
};
let mut parts = sort_text.split('.');
let Some(first) = parts.next() else { return };
let Some(second) = parts.next() else { return };