Use u64
instead of usize
in ElementId
(#29493)
Truncation to a 32 bit `usize` could cause two distinct IDs to be considered the same element. Release Notes: - N/A
This commit is contained in:
parent
bb7a5b13df
commit
60ec55b179
9 changed files with 25 additions and 22 deletions
|
@ -1,5 +1,4 @@
|
|||
use std::hash::{Hash, Hasher};
|
||||
use std::usize;
|
||||
use std::{ops::Range, path::Path, sync::Arc};
|
||||
|
||||
use collections::HashSet;
|
||||
|
@ -85,7 +84,7 @@ impl AgentContext {
|
|||
/// ID created at time of context add, for use in ElementId. This is not the stable identity of a
|
||||
/// context, instead that's handled by the `PartialEq` and `Hash` impls of `AgentContextKey`.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ContextId(usize);
|
||||
pub struct ContextId(u64);
|
||||
|
||||
impl ContextId {
|
||||
pub fn zero() -> Self {
|
||||
|
@ -93,7 +92,7 @@ impl ContextId {
|
|||
}
|
||||
|
||||
fn for_lookup() -> Self {
|
||||
ContextId(usize::MAX)
|
||||
ContextId(u64::MAX)
|
||||
}
|
||||
|
||||
pub fn post_inc(&mut self) -> Self {
|
||||
|
|
|
@ -388,7 +388,7 @@ impl ContextPicker {
|
|||
ContextMenuItem::custom_entry(
|
||||
move |_window, cx| {
|
||||
render_file_context_entry(
|
||||
ElementId::NamedInteger("ctx-recent".into(), ix),
|
||||
ElementId::named_usize("ctx-recent", ix),
|
||||
worktree_id,
|
||||
&path,
|
||||
&path_prefix,
|
||||
|
|
|
@ -169,7 +169,7 @@ impl PickerDelegate for FileContextPickerDelegate {
|
|||
.inset(true)
|
||||
.toggle_state(selected)
|
||||
.child(render_file_context_entry(
|
||||
ElementId::NamedInteger("file-ctx-picker".into(), ix),
|
||||
ElementId::named_usize("file-ctx-picker", ix),
|
||||
WorktreeId::from_usize(mat.worktree_id),
|
||||
&mat.path,
|
||||
&mat.path_prefix,
|
||||
|
|
|
@ -171,10 +171,7 @@ impl PickerDelegate for SymbolContextPickerDelegate {
|
|||
let mat = &self.matches[ix];
|
||||
|
||||
Some(ListItem::new(ix).inset(true).toggle_state(selected).child(
|
||||
render_symbol_context_entry(
|
||||
ElementId::NamedInteger("symbol-ctx-picker".into(), ix),
|
||||
mat,
|
||||
),
|
||||
render_symbol_context_entry(ElementId::named_usize("symbol-ctx-picker", ix), mat),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue