Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Merge branch 'main' into window_context_2
Antonio Scandurra136e59905175
diff --cc crates/collab_ui/src/collab_titlebar_item.rsindex 5d7eb4d2b46,b0b734f9cfd..4c177f0f00a--- a/crates/collab_ui/src/collab_titlebar_item.rs+++ b/crates/collab_ui/src/collab_titlebar_item.rs@@@ -457,11 -457,9 +457,9 @@@ impl CollabTitlebarItemSome(Stack::new().with_child(- MouseEventHandler::<ShareUnshare>::new(0, cx, |state, _| {+ MouseEventHandler::<ShareUnshare, Self>::new(0, cx, |state, _| {//TODO: Ensure this button has consistant width for both text variations- let style = titlebar- .share_button- .style_for(state, self.contacts_popover.is_some());+ let style = titlebar.share_button.style_for(state, false);Label::new(label, style.text.clone()).contained().with_style(style.container)diff --cc crates/editor/src/editor.rsindex dd4e466b9a9,b3f3723bc1a..d70ed96725b--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@@ -2352,53 -2352,66 +2352,66 @@@ impl Editorlet id = post_inc(&mut self.next_completion_id);let task = cx.spawn_weak(|this, mut cx| {async move {- let completions = completions.await?;- if completions.is_empty() {- return Ok(());- }-- let mut menu = CompletionsMenu {- id,- initial_position: position,- match_candidates: completions- .iter()- .enumerate()- .map(|(id, completion)| {- StringMatchCandidate::new(- id,- completion.label.text[completion.label.filter_range.clone()].into(),- )- })- .collect(),- buffer,- completions: completions.into(),- matches: Vec::new().into(),- selected_item: 0,- list: Default::default(),+ let menu = if let Some(completions) = completions.await.log_err() {+ let mut menu = CompletionsMenu {+ id,+ initial_position: position,+ match_candidates: completions+ .iter()+ .enumerate()+ .map(|(id, completion)| {+ StringMatchCandidate::new(+ id,+ completion.label.text[completion.label.filter_range.clone()]+ .into(),+ )+ })+ .collect(),+ buffer,+ completions: completions.into(),+ matches: Vec::new().into(),+ selected_item: 0,+ list: Default::default(),+ };+ menu.filter(query.as_deref(), cx.background()).await;+ if menu.matches.is_empty() {+ None+ } else {+ Some(menu)+ }+ } else {+ None};- menu.filter(query.as_deref(), cx.background()).await;-- if let Some(this) = this.upgrade(&cx) {- this.update(&mut cx, |this, cx| {- match this.context_menu.as_ref() {- None => {}- Some(ContextMenu::Completions(prev_menu)) => {- if prev_menu.id > menu.id {- return;- }+ let this = this+ .upgrade(&cx)+ .ok_or_else(|| anyhow!("editor was dropped"))?;+ this.update(&mut cx, |this, cx| {+ this.completion_tasks.retain(|(task_id, _)| *task_id > id);++ match this.context_menu.as_ref() {+ None => {}+ Some(ContextMenu::Completions(prev_menu)) => {+ if prev_menu.id > id {+ return;}- _ => return,}+ _ => return,+ }- this.completion_tasks.retain(|(id, _)| *id > menu.id);- if this.focused && !menu.matches.is_empty() {- this.show_context_menu(ContextMenu::Completions(menu), cx);- } else if this.hide_context_menu(cx).is_none() {+ if this.focused && menu.is_some() {+ let menu = menu.unwrap();+ this.show_context_menu(ContextMenu::Completions(menu), cx);+ } else if this.completion_tasks.is_empty() {+ // If there are no more completion tasks and the last menu was+ // empty, we should hide it. If it was already hidden, we should+ // also show the copilot suggestion when available.+ if this.hide_context_menu(cx).is_none() {this.update_visible_copilot_suggestion(cx);}- })?;- }+ }- });++ })?;+Ok::<_, anyhow::Error>(())}.log_err()