mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 18:25:57 +00:00
Clear copilot suggestions when hitting escape
Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
ef6c28326d
commit
d236d9e8c9
1 changed files with 8 additions and 2 deletions
|
@ -97,7 +97,6 @@ const MIN_NAVIGATION_HISTORY_ROW_DELTA: i64 = 10;
|
||||||
const MAX_SELECTION_HISTORY_LEN: usize = 1024;
|
const MAX_SELECTION_HISTORY_LEN: usize = 1024;
|
||||||
|
|
||||||
pub const FORMAT_TIMEOUT: Duration = Duration::from_secs(2);
|
pub const FORMAT_TIMEOUT: Duration = Duration::from_secs(2);
|
||||||
pub const COPILOT_TIMEOUT: Duration = Duration::from_secs(1);
|
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, PartialEq, Default)]
|
#[derive(Clone, Deserialize, PartialEq, Default)]
|
||||||
pub struct SelectNext {
|
pub struct SelectNext {
|
||||||
|
@ -1825,6 +1824,10 @@ impl Editor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.clear_copilot_suggestions(cx) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if self.snippet_stack.pop().is_some() {
|
if self.snippet_stack.pop().is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2870,13 +2873,16 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_copilot_suggestions(&mut self, cx: &mut ViewContext<Self>) {
|
fn clear_copilot_suggestions(&mut self, cx: &mut ViewContext<Self>) -> bool {
|
||||||
self.display_map
|
self.display_map
|
||||||
.update(cx, |map, cx| map.replace_suggestion::<usize>(None, cx));
|
.update(cx, |map, cx| map.replace_suggestion::<usize>(None, cx));
|
||||||
|
let was_empty = self.copilot_state.completions.is_empty();
|
||||||
self.copilot_state.completions.clear();
|
self.copilot_state.completions.clear();
|
||||||
self.copilot_state.active_completion_index = 0;
|
self.copilot_state.active_completion_index = 0;
|
||||||
self.copilot_state.pending_refresh = Task::ready(None);
|
self.copilot_state.pending_refresh = Task::ready(None);
|
||||||
self.copilot_state.position = Anchor::min();
|
self.copilot_state.position = Anchor::min();
|
||||||
|
cx.notify();
|
||||||
|
!was_empty
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_code_actions_indicator(
|
pub fn render_code_actions_indicator(
|
||||||
|
|
Loading…
Reference in a new issue