This commit is contained in:
Antonio Scandurra 2023-08-25 13:36:52 +02:00
parent 971c833e80
commit 0444b5a775

View file

@ -214,12 +214,12 @@ impl AssistantPanel {
} }
fn inline_assist(workspace: &mut Workspace, _: &InlineAssist, cx: &mut ViewContext<Workspace>) { fn inline_assist(workspace: &mut Workspace, _: &InlineAssist, cx: &mut ViewContext<Workspace>) {
let assistant = if let Some(assistant) = workspace.panel::<AssistantPanel>(cx) { let this = if let Some(this) = workspace.panel::<AssistantPanel>(cx) {
if assistant if this
.update(cx, |assistant, cx| assistant.load_api_key(cx)) .update(cx, |assistant, cx| assistant.load_api_key(cx))
.is_some() .is_some()
{ {
assistant this
} else { } else {
workspace.focus_panel::<AssistantPanel>(cx); workspace.focus_panel::<AssistantPanel>(cx);
return; return;
@ -237,7 +237,7 @@ impl AssistantPanel {
return; return;
}; };
assistant.update(cx, |assistant, cx| { this.update(cx, |assistant, cx| {
assistant.new_inline_assist(&active_editor, cx) assistant.new_inline_assist(&active_editor, cx)
}); });
} }
@ -1046,7 +1046,7 @@ impl AssistantPanel {
.position(|editor| editor.read(cx).conversation.read(cx).path.as_deref() == Some(path)) .position(|editor| editor.read(cx).conversation.read(cx).path.as_deref() == Some(path))
} }
pub fn load_api_key(&mut self, cx: &mut ViewContext<Self>) -> Option<String> { fn load_api_key(&mut self, cx: &mut ViewContext<Self>) -> Option<String> {
if self.api_key.borrow().is_none() && !self.has_read_credentials { if self.api_key.borrow().is_none() && !self.has_read_credentials {
self.has_read_credentials = true; self.has_read_credentials = true;
let api_key = if let Ok(api_key) = env::var("OPENAI_API_KEY") { let api_key = if let Ok(api_key) = env::var("OPENAI_API_KEY") {