view/thread.rs: fix expanded_hash argument off by one error
When calling ThreadView::new with an envelope hash, Some(expanded_hash), in the arguments, when translating it to a cursor position (usize) it was mistakenly subtracted with 1 resulting in the wrong thread entry showing up as expanded.pull/227/head
parent
45bac6eb16
commit
fdc0861ac0
|
@ -103,16 +103,27 @@ impl<T> RowsState<T> {
|
|||
entry_strings: EntryStrings,
|
||||
) {
|
||||
env_hashes.dedup();
|
||||
env_hashes.retain(|h| !self.all_envelopes.contains(h));
|
||||
if env_hashes.is_empty() {
|
||||
return;
|
||||
}
|
||||
let index = self.entries.len();
|
||||
self.thread_order.insert(thread, index);
|
||||
self.all_threads.insert(thread);
|
||||
for &env_hash in &env_hashes {
|
||||
self.selection.insert(env_hash, false);
|
||||
self.env_to_thread.insert(env_hash, thread);
|
||||
self.env_order.insert(env_hash, index);
|
||||
self.all_envelopes.insert(env_hash);
|
||||
}
|
||||
self.thread_to_env.insert(thread, env_hashes);
|
||||
if !self.all_threads.contains(&thread) {
|
||||
self.thread_order.insert(thread, index);
|
||||
self.all_threads.insert(thread);
|
||||
self.thread_to_env.insert(thread, env_hashes);
|
||||
} else {
|
||||
self.thread_to_env
|
||||
.entry(thread)
|
||||
.or_default()
|
||||
.extend_from_slice(&env_hashes);
|
||||
}
|
||||
self.entries.push((metadata, entry_strings));
|
||||
}
|
||||
|
||||
|
|
|
@ -782,12 +782,7 @@ impl ThreadListing {
|
|||
}
|
||||
|
||||
fn get_env_under_cursor(&self, cursor: usize) -> Option<EnvelopeHash> {
|
||||
self.rows
|
||||
.env_order
|
||||
.iter()
|
||||
.find(|(_, &r)| r == cursor)
|
||||
.map(|v| v.0)
|
||||
.cloned()
|
||||
self.rows.entries.get(cursor).map(|v| (v.0).1)
|
||||
}
|
||||
|
||||
fn make_entry_string(&self, e: &Envelope, context: &Context) -> EntryStrings {
|
||||
|
|
|
@ -231,7 +231,7 @@ impl ThreadView {
|
|||
};
|
||||
match expanded_hash {
|
||||
Some(expanded_hash) if expanded_hash == entry.msg_hash => {
|
||||
self.new_expanded_pos = self.entries.len().saturating_sub(1);
|
||||
self.new_expanded_pos = self.entries.len();
|
||||
self.expanded_pos = self.new_expanded_pos + 1;
|
||||
}
|
||||
_ => {}
|
||||
|
|
Loading…
Reference in New Issue