From d868ec920f4bb13132921c0d29f451a288befc75 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 1 Sep 2023 09:15:29 +0200 Subject: [PATCH] Avoid duplicate entries in inline assistant's prompt history --- crates/ai/src/assistant.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 5cde99af82..9b384252fc 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -507,10 +507,13 @@ impl AssistantPanel { return; }; + self.inline_prompt_history + .retain(|prompt| prompt != user_prompt); self.inline_prompt_history.push_back(user_prompt.into()); if self.inline_prompt_history.len() > Self::INLINE_PROMPT_HISTORY_MAX_LEN { self.inline_prompt_history.pop_front(); } + let range = pending_assist.range.clone(); let snapshot = editor.read(cx).buffer().read(cx).snapshot(cx); let selected_text = snapshot