clock: Cleanup ReplicaId, Lamport and Global (#40600)

- Notable change is the use of a newtype for `ReplicaId`
- Fixes `WorktreeStore::create_remote_worktree` creating a remote
worktree with the local replica id, though this is not currently used
- Fixes observing the `Agent` (that is following the agent) causing
global clocks to allocate 65535 elements
- Shrinks the size of `Global` a bit. In a local or non-collab remote
session it won't ever allocate still.

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-20 13:26:20 +02:00
committed by GitHub
parent 37e264ab99
commit 43a9368dff
33 changed files with 427 additions and 284 deletions
+5 -5
View File
@@ -1278,7 +1278,7 @@ mod tests {
Anchor::min(),
&InlayHint {
label: InlayHintLabel::String("a".to_string()),
position: text::Anchor::default(),
position: text::Anchor::MIN,
padding_left: false,
padding_right: false,
tooltip: None,
@@ -1298,7 +1298,7 @@ mod tests {
Anchor::min(),
&InlayHint {
label: InlayHintLabel::String("a".to_string()),
position: text::Anchor::default(),
position: text::Anchor::MIN,
padding_left: true,
padding_right: true,
tooltip: None,
@@ -1318,7 +1318,7 @@ mod tests {
Anchor::min(),
&InlayHint {
label: InlayHintLabel::String(" a ".to_string()),
position: text::Anchor::default(),
position: text::Anchor::MIN,
padding_left: false,
padding_right: false,
tooltip: None,
@@ -1338,7 +1338,7 @@ mod tests {
Anchor::min(),
&InlayHint {
label: InlayHintLabel::String(" a ".to_string()),
position: text::Anchor::default(),
position: text::Anchor::MIN,
padding_left: true,
padding_right: true,
tooltip: None,
@@ -1361,7 +1361,7 @@ mod tests {
Anchor::min(),
&InlayHint {
label: InlayHintLabel::String("🎨".to_string()),
position: text::Anchor::default(),
position: text::Anchor::MIN,
padding_left: true,
padding_right: true,
tooltip: None,
+3 -3
View File
@@ -82,7 +82,7 @@ use anyhow::{Context as _, Result, anyhow};
use blink_manager::BlinkManager;
use buffer_diff::DiffHunkStatus;
use client::{Collaborator, ParticipantIndex, parse_zed_link};
use clock::{AGENT_REPLICA_ID, ReplicaId};
use clock::ReplicaId;
use code_context_menus::{
AvailableCodeAction, CodeActionContents, CodeActionsItem, CodeActionsMenu, CodeContextMenu,
CompletionsMenu, ContextMenuOrigin,
@@ -1301,7 +1301,7 @@ enum SelectionHistoryMode {
#[derive(Clone, PartialEq, Eq, Hash)]
struct HoveredCursor {
replica_id: u16,
replica_id: ReplicaId,
selection_id: usize,
}
@@ -23482,7 +23482,7 @@ impl EditorSnapshot {
self.buffer_snapshot()
.selections_in_range(range, false)
.filter_map(move |(replica_id, line_mode, cursor_shape, selection)| {
if replica_id == AGENT_REPLICA_ID {
if replica_id == ReplicaId::AGENT {
Some(RemoteSelection {
replica_id,
selection,