From 1b09862384e84169c84bd7047bfbd21df7392c50 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 19 Dec 2023 14:11:59 -0800 Subject: [PATCH 1/3] Restrcit context for some editor bindings that don't apply to single-line editors --- assets/keymaps/default.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index b8d3711132b1063543e7554b88d014df21460361..5d700006393ea27a4e46348f08866ab3197f8215 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -502,7 +502,7 @@ } }, { - "context": "Editor", + "context": "Editor && mode == full", "bindings": { "alt-enter": "editor::OpenExcerpts", "cmd-f8": "editor::GoToHunk", From 901795bcb98b9d85cfab42c95368e792122e7ca0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 19 Dec 2023 14:12:29 -0800 Subject: [PATCH 2/3] Don't reset the collab panel when it loses focus --- crates/collab_ui2/src/collab_panel.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/crates/collab_ui2/src/collab_panel.rs b/crates/collab_ui2/src/collab_panel.rs index b7dd24b9ab5fc0b4eea338316fac95060c468d47..28d1b12beafb62c71718a6df68f1bff94e9616cc 100644 --- a/crates/collab_ui2/src/collab_panel.rs +++ b/crates/collab_ui2/src/collab_panel.rs @@ -199,12 +199,6 @@ impl CollabPanel { .iter() .position(|entry| !matches!(entry, ListEntry::Header(_))); } - } else if let editor::EditorEvent::Blurred = event { - let query = this.filter_editor.read(cx).text(cx); - if query.is_empty() { - this.selection.take(); - this.update_entries(true, cx); - } } }) .detach(); From afd3bf77467849d3f0aad3639ce7ef9f720e3be0 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 19 Dec 2023 14:12:45 -0800 Subject: [PATCH 3/3] Add missing selected state and keyboard action for some collab panel items --- crates/collab_ui2/src/collab_panel.rs | 107 +++++++++++------- .../src/collab_panel/contact_finder.rs | 6 +- 2 files changed, 69 insertions(+), 44 deletions(-) diff --git a/crates/collab_ui2/src/collab_panel.rs b/crates/collab_ui2/src/collab_panel.rs index 28d1b12beafb62c71718a6df68f1bff94e9616cc..35e2f8d7ed210dc3cfb2fbe59d1d399a3f2683b9 100644 --- a/crates/collab_ui2/src/collab_panel.rs +++ b/crates/collab_ui2/src/collab_panel.rs @@ -804,8 +804,9 @@ impl CollabPanel { user: &Arc, peer_id: Option, is_pending: bool, + is_selected: bool, cx: &mut ViewContext, - ) -> impl IntoElement { + ) -> ListItem { let is_current_user = self.user_store.read(cx).current_user().map(|user| user.id) == Some(user.id); let tooltip = format!("Follow {}", user.github_login); @@ -813,6 +814,7 @@ impl CollabPanel { ListItem::new(SharedString::from(user.github_login.clone())) .start_slot(Avatar::new(user.avatar_uri.clone())) .child(Label::new(user.github_login.clone())) + .selected(is_selected) .end_slot(if is_pending { Label::new("Calling").color(Color::Muted).into_any_element() } else if is_current_user { @@ -839,10 +841,8 @@ impl CollabPanel { project_id: u64, worktree_root_names: &[String], host_user_id: u64, - // is_current: bool, is_last: bool, is_selected: bool, - // theme: &theme::Theme, cx: &mut ViewContext, ) -> impl IntoElement { let project_name: SharedString = if worktree_root_names.is_empty() { @@ -917,9 +917,11 @@ impl CollabPanel { fn render_channel_notes( &self, channel_id: ChannelId, + is_selected: bool, cx: &mut ViewContext, ) -> impl IntoElement { ListItem::new("channel-notes") + .selected(is_selected) .on_click(cx.listener(move |this, _, cx| { this.open_channel_notes(channel_id, cx); })) @@ -936,9 +938,11 @@ impl CollabPanel { fn render_channel_chat( &self, channel_id: ChannelId, + is_selected: bool, cx: &mut ViewContext, ) -> impl IntoElement { ListItem::new("channel-chat") + .selected(is_selected) .on_click(cx.listener(move |this, _, cx| { this.join_channel_chat(channel_id, cx); })) @@ -1136,32 +1140,32 @@ impl CollabPanel { self.call(contact.user.id, cx); } } - // ListEntry::ParticipantProject { - // project_id, - // host_user_id, - // .. - // } => { - // if let Some(workspace) = self.workspace.upgrade(cx) { - // let app_state = workspace.read(cx).app_state().clone(); - // workspace::join_remote_project( - // *project_id, - // *host_user_id, - // app_state, - // cx, - // ) - // .detach_and_log_err(cx); - // } - // } - // ListEntry::ParticipantScreen { peer_id, .. } => { - // let Some(peer_id) = peer_id else { - // return; - // }; - // if let Some(workspace) = self.workspace.upgrade(cx) { - // workspace.update(cx, |workspace, cx| { - // workspace.open_shared_screen(*peer_id, cx) - // }); - // } - // } + ListEntry::ParticipantProject { + project_id, + host_user_id, + .. + } => { + if let Some(workspace) = self.workspace.upgrade() { + let app_state = workspace.read(cx).app_state().clone(); + workspace::join_remote_project( + *project_id, + *host_user_id, + app_state, + cx, + ) + .detach_and_log_err(cx); + } + } + ListEntry::ParticipantScreen { peer_id, .. } => { + let Some(peer_id) = peer_id else { + return; + }; + if let Some(workspace) = self.workspace.upgrade() { + workspace.update(cx, |workspace, cx| { + workspace.open_shared_screen(*peer_id, cx) + }); + } + } ListEntry::Channel { channel, .. } => { let is_active = maybe!({ let call_channel = ActiveCall::global(cx) @@ -1180,7 +1184,30 @@ impl CollabPanel { } } ListEntry::ContactPlaceholder => self.toggle_contact_finder(cx), - _ => {} + ListEntry::CallParticipant { user, peer_id, .. } => { + if Some(user) == self.user_store.read(cx).current_user().as_ref() { + Self::leave_call(cx); + } else if let Some(peer_id) = peer_id { + self.workspace + .update(cx, |workspace, cx| workspace.follow(*peer_id, cx)) + .ok(); + } + } + ListEntry::IncomingRequest(user) => { + self.respond_to_contact_request(user.id, true, cx) + } + ListEntry::ChannelInvite(channel) => { + self.respond_to_channel_invite(channel.id, true, cx) + } + ListEntry::ChannelNotes { channel_id } => { + self.open_channel_notes(*channel_id, cx) + } + ListEntry::ChannelChat { channel_id } => { + self.join_channel_chat(*channel_id, cx) + } + + ListEntry::OutgoingRequest(_) => {} + ListEntry::ChannelEditor { .. } => {} } } } @@ -1673,7 +1700,7 @@ impl CollabPanel { peer_id, is_pending, } => self - .render_call_participant(user, *peer_id, *is_pending, cx) + .render_call_participant(user, *peer_id, *is_pending, is_selected, cx) .into_any_element(), ListEntry::ParticipantProject { project_id, @@ -1694,11 +1721,11 @@ impl CollabPanel { .render_participant_screen(*peer_id, *is_last, is_selected, cx) .into_any_element(), ListEntry::ChannelNotes { channel_id } => self - .render_channel_notes(*channel_id, cx) + .render_channel_notes(*channel_id, is_selected, cx) + .into_any_element(), + ListEntry::ChannelChat { channel_id } => self + .render_channel_chat(*channel_id, is_selected, cx) .into_any_element(), - ListEntry::ChannelChat { channel_id } => { - self.render_channel_chat(*channel_id, cx).into_any_element() - } } } @@ -1953,7 +1980,7 @@ impl CollabPanel { channel: &Arc, is_selected: bool, cx: &mut ViewContext, - ) -> impl IntoElement { + ) -> ListItem { let channel_id = channel.id; let response_is_pending = self .channel_store @@ -2000,7 +2027,7 @@ impl CollabPanel { &self, is_selected: bool, cx: &mut ViewContext, - ) -> impl IntoElement { + ) -> ListItem { ListItem::new("contact-placeholder") .child(IconElement::new(Icon::Plus)) .child(Label::new("Add a Contact")) @@ -2087,9 +2114,8 @@ impl CollabPanel { })) .child( ListItem::new(channel_id as usize) - // Offset the indent depth by one to give us room to show the disclosure. + // Add one level of depth for the disclosure arrow. .indent_level(depth + 1) - .indent_step_size(cx.rem_size() * 14.0 / 16.0) // @todo()! @nate this is to step over the disclosure toggle .selected(is_selected || is_active) .toggle(disclosed) .on_toggle( @@ -2158,7 +2184,8 @@ impl CollabPanel { fn render_channel_editor(&self, depth: usize, _cx: &mut ViewContext) -> impl IntoElement { let item = ListItem::new("channel-editor") .inset(false) - .indent_level(depth) + // Add one level of depth for the disclosure arrow. + .indent_level(depth + 1) .start_slot( IconElement::new(Icon::Hash) .size(IconSize::Small) diff --git a/crates/collab_ui2/src/collab_panel/contact_finder.rs b/crates/collab_ui2/src/collab_panel/contact_finder.rs index 208727efd27132debb9f883af7c172154d2461f1..31d836279b6a17d4b119dcad0d562d66388f30ac 100644 --- a/crates/collab_ui2/src/collab_panel/contact_finder.rs +++ b/crates/collab_ui2/src/collab_panel/contact_finder.rs @@ -1,9 +1,7 @@ -#![allow(unused)] use client::{ContactRequestStatus, User, UserStore}; use gpui::{ - div, img, svg, AnyElement, AppContext, DismissEvent, Div, Entity, EventEmitter, FocusHandle, - FocusableView, Img, IntoElement, Model, ParentElement as _, Render, Styled, Task, View, - ViewContext, VisualContext, WeakView, + AppContext, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView, Model, + ParentElement as _, Render, Styled, Task, View, ViewContext, VisualContext, WeakView, }; use picker::{Picker, PickerDelegate}; use std::sync::Arc;