Terminal Markdown previewer — GUI-like experience.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: optimize status hash

RivoLink 4ce87ddd 535ef9d0

+16 -2
+4 -2
src/app/mod.rs
··· 153 153 query: String::new(), 154 154 matches: vec![], 155 155 idx: 0, 156 + draft_hash: 0, 157 + query_hash: 0, 156 158 }, 157 159 debug_input, 158 160 filename, ··· 340 342 let cache_key = StatusCacheKey { 341 343 pct, 342 344 search_mode: self.search.mode, 343 - search_draft_hash: hash_str(&self.search.draft), 344 - search_query_hash: hash_str(&self.search.query), 345 + search_draft_hash: self.search.draft_hash, 346 + search_query_hash: self.search.query_hash, 345 347 search_draft_len: self.search.draft.len(), 346 348 search_query_len: self.search.query.len(), 347 349 search_match_count: self.search.matches.len(),
+12
src/app/search.rs
··· 1 1 use super::App; 2 + use crate::markdown::hash_str; 2 3 3 4 pub(crate) struct SearchState { 4 5 pub(super) mode: bool, ··· 6 7 pub(super) query: String, 7 8 pub(super) matches: Vec<usize>, 8 9 pub(super) idx: usize, 10 + pub(super) draft_hash: u64, 11 + pub(super) query_hash: u64, 9 12 } 10 13 11 14 impl App { ··· 32 35 #[cfg(test)] 33 36 pub(crate) fn set_search_query(&mut self, query: impl Into<String>) { 34 37 self.search.query = query.into(); 38 + self.search.query_hash = hash_str(&self.search.query); 35 39 } 36 40 37 41 pub(crate) fn search_match_count(&self) -> usize { ··· 50 54 #[cfg(test)] 51 55 pub(crate) fn set_search_draft(&mut self, draft: impl Into<String>) { 52 56 self.search.draft = draft.into(); 57 + self.search.draft_hash = hash_str(&self.search.draft); 53 58 } 54 59 55 60 pub(crate) fn pop_search_draft(&mut self) { 56 61 self.search.draft.pop(); 62 + self.search.draft_hash = hash_str(&self.search.draft); 57 63 } 58 64 59 65 pub(crate) fn push_search_draft(&mut self, ch: char) { 60 66 self.search.draft.push(ch); 67 + self.search.draft_hash = hash_str(&self.search.draft); 61 68 } 62 69 63 70 pub(crate) fn run_search(&mut self) { ··· 83 90 pub(crate) fn begin_search(&mut self) { 84 91 self.search.mode = true; 85 92 self.search.draft = self.search.query.clone(); 93 + self.search.draft_hash = self.search.query_hash; 86 94 crate::runtime::debug_log( 87 95 self.debug_input, 88 96 &format!( ··· 100 108 self.search.query.clear(); 101 109 self.search.matches.clear(); 102 110 self.search.idx = 0; 111 + self.search.draft_hash = 0; 112 + self.search.query_hash = 0; 103 113 } 104 114 105 115 pub(crate) fn cancel_search(&mut self) { ··· 112 122 self.search.mode = false; 113 123 let draft = std::mem::take(&mut self.search.draft); 114 124 self.search.query = draft; 125 + self.search.query_hash = self.search.draft_hash; 126 + self.search.draft_hash = 0; 115 127 if self.search.query.is_empty() { 116 128 self.reset_search_state(); 117 129 crate::runtime::debug_log(