Skip to content

Commit

Permalink
assume clamping semantics in selection panel
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 8, 2024
1 parent 00a83ab commit bc9bbbb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions crates/re_query_cache2/src/latest_at/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,23 @@ impl CachedLatestAtComponentResults {
re_log::debug_once!("Couldn't deserialize {component_name}: promise still pending",);
None
}
PromiseResult::Ready(data) if data.len() > index => Some(data[index].clone()),
PromiseResult::Ready(data) => {
re_log::log_once!(
// TODO(#5303): Figure out we'd like to integrate clamping semantics into selection panel.
//
// For now, we simply always clamp, which is the closest to the legacy behavior that the UI
// expects.
let index = usize::min(index, data.len().saturating_sub(1));

if data.len() > index {
Some(data[index].clone())
} else {
re_log::log_once!(
level,
"Couldn't deserialize {component_name}: index not found (index: {index}, length: {})",
data.len(),
);
None
None
}
}
PromiseResult::Error(err) => {
re_log::log_once!(
Expand Down

0 comments on commit bc9bbbb

Please sign in to comment.