mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 19:10:24 +00:00
Hide cursors by default, but show some
This commit is contained in:
parent
0ca9f286c6
commit
ef0432da0d
2 changed files with 46 additions and 1 deletions
|
@ -569,6 +569,8 @@ pub struct Editor {
|
||||||
project: Option<Model<Project>>,
|
project: Option<Model<Project>>,
|
||||||
collaboration_hub: Option<Box<dyn CollaborationHub>>,
|
collaboration_hub: Option<Box<dyn CollaborationHub>>,
|
||||||
blink_manager: Model<BlinkManager>,
|
blink_manager: Model<BlinkManager>,
|
||||||
|
recently_focused: bool,
|
||||||
|
hovered_selections: HashSet<(ReplicaId, usize)>,
|
||||||
pub show_local_selections: bool,
|
pub show_local_selections: bool,
|
||||||
mode: EditorMode,
|
mode: EditorMode,
|
||||||
show_gutter: bool,
|
show_gutter: bool,
|
||||||
|
@ -1808,6 +1810,8 @@ impl Editor {
|
||||||
pixel_position_of_newest_cursor: None,
|
pixel_position_of_newest_cursor: None,
|
||||||
gutter_width: Default::default(),
|
gutter_width: Default::default(),
|
||||||
style: None,
|
style: None,
|
||||||
|
recently_focused: false,
|
||||||
|
hovered_selections: Default::default(),
|
||||||
editor_actions: Default::default(),
|
editor_actions: Default::default(),
|
||||||
show_copilot_suggestions: mode == EditorMode::Full,
|
show_copilot_suggestions: mode == EditorMode::Full,
|
||||||
_subscriptions: vec![
|
_subscriptions: vec![
|
||||||
|
@ -9196,6 +9200,16 @@ impl Editor {
|
||||||
cx.focus(&rename_editor_focus_handle);
|
cx.focus(&rename_editor_focus_handle);
|
||||||
} else {
|
} else {
|
||||||
self.blink_manager.update(cx, BlinkManager::enable);
|
self.blink_manager.update(cx, BlinkManager::enable);
|
||||||
|
self.recently_focused = true;
|
||||||
|
cx.spawn(|this, mut cx| async move {
|
||||||
|
cx.background_executor().timer(Duration::from_secs(5)).await;
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
|
this.recently_focused = false;
|
||||||
|
cx.notify()
|
||||||
|
})
|
||||||
|
.ok()
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
self.buffer.update(cx, |buffer, cx| {
|
self.buffer.update(cx, |buffer, cx| {
|
||||||
buffer.finalize_last_transaction(cx);
|
buffer.finalize_last_transaction(cx);
|
||||||
if self.leader_peer_id.is_none() {
|
if self.leader_peer_id.is_none() {
|
||||||
|
|
|
@ -586,6 +586,32 @@ impl EditorElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_visible_cursor(
|
||||||
|
editor: &mut Editor,
|
||||||
|
point: DisplayPoint,
|
||||||
|
cx: &mut ViewContext<Editor>,
|
||||||
|
) {
|
||||||
|
let snapshot = editor.snapshot(cx);
|
||||||
|
if let Some(hub) = editor.collaboration_hub() {
|
||||||
|
let range = if point.column() > 0 {
|
||||||
|
DisplayPoint::new(point.row(), point.column() - 1)..point
|
||||||
|
} else {
|
||||||
|
point..DisplayPoint::new(point.row(), point.column() + 1)
|
||||||
|
};
|
||||||
|
let range = snapshot
|
||||||
|
.buffer_snapshot
|
||||||
|
.anchor_at(range.start.to_point(&snapshot.display_snapshot), Bias::Left)
|
||||||
|
..snapshot
|
||||||
|
.buffer_snapshot
|
||||||
|
.anchor_at(range.end.to_point(&snapshot.display_snapshot), Bias::Right);
|
||||||
|
for selection in snapshot.remote_selections_in_range(&range, hub, cx) {
|
||||||
|
let key = (selection.replica_id, selection.selection.id);
|
||||||
|
editor.hovered_selections.insert(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
editor.hovered_selections.clear();
|
||||||
|
}
|
||||||
|
|
||||||
fn paint_background(
|
fn paint_background(
|
||||||
&self,
|
&self,
|
||||||
gutter_bounds: Bounds<Pixels>,
|
gutter_bounds: Bounds<Pixels>,
|
||||||
|
@ -1962,6 +1988,7 @@ impl EditorElement {
|
||||||
if Some(selection.peer_id) == editor.leader_peer_id {
|
if Some(selection.peer_id) == editor.leader_peer_id {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let id = (selection.replica_id, selection.selection.id);
|
||||||
|
|
||||||
remote_selections
|
remote_selections
|
||||||
.entry(selection.replica_id)
|
.entry(selection.replica_id)
|
||||||
|
@ -1974,7 +2001,11 @@ impl EditorElement {
|
||||||
&snapshot.display_snapshot,
|
&snapshot.display_snapshot,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
selection.user_name,
|
if editor.recently_focused || editor.hovered_selections.contains(&id) {
|
||||||
|
selection.user_name
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue