From 4a7ebf660eb2c1fbd9b057f58d10d20ae7aabd44 Mon Sep 17 00:00:00 2001 From: Kenneth Date: Thu, 28 May 2026 22:43:52 +0100 Subject: [PATCH] chore: add missing fixture --- .../novem/src/query.rs/src/query.rs | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 fixtures/github/repo.diff/kennethnym/novem/src/query.rs/src/query.rs diff --git a/fixtures/github/repo.diff/kennethnym/novem/src/query.rs/src/query.rs b/fixtures/github/repo.diff/kennethnym/novem/src/query.rs/src/query.rs new file mode 100644 index 0000000..4d54fc0 --- /dev/null +++ b/fixtures/github/repo.diff/kennethnym/novem/src/query.rs/src/query.rs @@ -0,0 +1,110 @@ +--- a/src/query.rs ++++ b/src/query.rs +@@ -1,56 +1,82 @@ +-use std::collections::HashMap; ++use std::{collections::HashMap, time::SystemTime}; + + #[derive(Clone, Default)] +-pub struct CachedSelection { +- pub issue_id: Option, ++pub struct CachedQueryState { ++ pub selected_issue_id: Option, ++ pub selected_pull_request_id: Option, ++ pub scroll_anchor: Option, + pub scroll_offset: usize, ++ pub stale_at: Option, + } + + #[derive(Default)] + pub struct QueryStore { +- entries: HashMap, ++ entries: HashMap, + } + + impl QueryStore { +- pub fn snapshot(&self, key: &str) -> Option { +- self.entries.get(key).cloned() +- } +- +- pub fn remember( ++ pub fn remember_issue_state( + &mut self, + key: impl Into, +- issue_id: Option, ++ selected_issue_id: Option, ++ selected_pull_request_id: Option, ++ scroll_anchor: Option, + scroll_offset: usize, + ) { + self.entries.insert( + key.into(), +- CachedSelection { +- issue_id, ++ CachedQueryState { ++ selected_issue_id, ++ selected_pull_request_id, ++ scroll_anchor, + scroll_offset, ++ stale_at: None, + }, + ); + } + +- pub fn clear(&mut self, key: &str) { +- self.entries.remove(key); ++ pub fn snapshot(&self, key: &str) -> Option { ++ self.entries.get(key).cloned() + } ++ ++ pub fn clear_stale(&mut self) { ++ self.entries ++ .retain(|_, state| state.stale_at.is_none() || state.selected_issue_id.is_some()); ++ } ++ ++ pub fn remove(&mut self, key: &str) -> Option { ++ self.entries.remove(key) ++ } + } + +-pub fn reconcile_selection( +- cached: Option<&CachedSelection>, ++pub fn reconcile_selected_issue( ++ cached: Option<&CachedQueryState>, + visible_ids: &[String], + ) -> Option { +- let current = cached.and_then(|state| state.issue_id.clone()); ++ let cached_issue = cached.and_then(|state| state.selected_issue_id.as_ref()); + +- if let Some(id) = current.as_ref() { +- if visible_ids.iter().any(|visible| visible == id) { +- return Some(id.clone()); +- } +- } ++ cached_issue ++ .filter(|issue_id| visible_ids.iter().any(|visible| visible == *issue_id)) ++ .cloned() ++ .or_else(|| visible_ids.first().cloned()) ++} + +- visible_ids.first().cloned() ++pub fn reconcile_scroll_anchor( ++ cached: Option<&CachedQueryState>, ++ visible_ids: &[String], ++) -> Option { ++ cached ++ .and_then(|state| state.scroll_anchor.as_ref()) ++ .filter(|anchor| visible_ids.iter().any(|visible| visible == *anchor)) ++ .cloned() + } + +-pub fn should_repaint(cached: Option<&CachedSelection>, next_issue_id: Option<&str>) -> bool { +- cached.and_then(|state| state.issue_id.as_deref()) != next_issue_id ++pub fn should_repaint( ++ cached: Option<&CachedQueryState>, ++ next_issue_id: Option<&str>, ++ next_pull_request_id: Option<&str>, ++) -> bool { ++ cached.and_then(|state| state.selected_issue_id.as_deref()) != next_issue_id ++ || cached.and_then(|state| state.selected_pull_request_id.as_deref()) ++ != next_pull_request_id + }