Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fixed panic in new cycling code Made cycling fire without debounce
Mikayla Maki9b8a3e4de5d7
diff --git a/crates/copilot/src/sign_in.rs b/crates/copilot/src/sign_in.rsindex 4378c90c881..a65be325ce6 100644--- a/crates/copilot/src/sign_in.rs+++ b/crates/copilot/src/sign_in.rs@@ -5,7 +5,7 @@ use gpui::{platform::{WindowBounds, WindowKind, WindowOptions},AppContext, ClipboardItem, Element, Entity, View, ViewContext, ViewHandle,};-use settings::{settings_file::SettingsFile, Settings};+use settings::Settings;use theme::ui::modal;#[derive(PartialEq, Eq, Debug, Clone)]diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex cba98c73c52..de47fbd4edf 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -1083,8 +1083,12 @@ impl CopilotState {};}Direction::Next => {- self.active_completion_index =- (self.active_completion_index + 1) % self.completions.len();+ if self.completions.len() == 0 {+ self.active_completion_index = 0+ } else {+ self.active_completion_index =+ (self.active_completion_index + 1) % self.completions.len();+ }}}}@@ -2850,22 +2854,15 @@ impl Editor {self.copilot_state.pending_refresh = cx.spawn_weak(|this, mut cx| async move {cx.background().timer(COPILOT_DEBOUNCE_TIMEOUT).await;- let mut completions = Vec::new();-- // let completions_iter = if cycling {- let completions_iter = copilot+ let completions = copilot.update(&mut cx, |copilot, cx| {copilot.completions(&buffer, buffer_position, cx)})- .await;- // } else {- // copilot- // .update(&mut cx, |copilot, cx| {- // copilot.completions_cycling(&buffer, buffer_position, cx)- // })- // .await- // };- completions.extend(completions_iter.log_err().into_iter().flatten());+ .await+ .log_err()+ .into_iter()+ .flatten()+ .collect_vec();this.upgrade(&cx)?.update(&mut cx, |this, cx| {if !completions.is_empty() {@@ -2937,11 +2934,11 @@ impl Editor {}fn next_copilot_suggestion(&mut self, _: &copilot::NextSuggestion, cx: &mut ViewContext<Self>) {- if self.has_active_copilot_suggestion(cx) {- self.cycle_suggestions(Direction::Next, cx);- } else {- self.refresh_copilot_suggestions(cx);- }+ // if self.has_active_copilot_suggestion(cx) {+ self.cycle_suggestions(Direction::Next, cx);+ // } else {+ // self.refresh_copilot_suggestions(cx);+ // }}fn previous_copilot_suggestion(@@ -2949,11 +2946,11 @@ impl Editor {_: &copilot::PreviousSuggestion,cx: &mut ViewContext<Self>,) {- if self.has_active_copilot_suggestion(cx) {- self.cycle_suggestions(Direction::Prev, cx);- } else {- self.refresh_copilot_suggestions(cx);- }+ // if self.has_active_copilot_suggestion(cx) {+ self.cycle_suggestions(Direction::Prev, cx);+ // } else {+ // self.refresh_copilot_suggestions(cx);+ // }}fn accept_copilot_suggestion(&mut self, cx: &mut ViewContext<Self>) -> bool {