From 55bf45d2657278da8c1a4d70ae4baca2099b510d Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Sat, 26 Aug 2023 12:07:03 +0200 Subject: [PATCH] Add disabled style for prompt editor after confirming --- crates/ai/src/assistant.rs | 11 +++++++++-- crates/editor/src/editor.rs | 9 +++++++++ crates/theme/src/theme.rs | 1 + styles/src/style_tree/assistant.ts | 10 +++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index c5bf027fcc..f7abcdf748 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -2871,8 +2871,15 @@ impl InlineAssistant { cx.emit(InlineAssistantEvent::Dismissed); } else { let prompt = self.prompt_editor.read(cx).text(cx); - self.prompt_editor - .update(cx, |editor, _| editor.set_read_only(true)); + self.prompt_editor.update(cx, |editor, cx| { + editor.set_read_only(true); + editor.set_field_editor_style( + Some(Arc::new(|theme| { + theme.assistant.inline.disabled_editor.clone() + })), + cx, + ); + }); cx.emit(InlineAssistantEvent::Confirmed { prompt }); self.confirmed = true; } diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index d5141a7f7d..75fb6006c0 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1606,6 +1606,15 @@ impl Editor { self.read_only = read_only; } + pub fn set_field_editor_style( + &mut self, + style: Option>, + cx: &mut ViewContext, + ) { + self.get_field_editor_theme = style; + cx.notify(); + } + pub fn replica_id_map(&self) -> Option<&HashMap> { self.replica_id_mapping.as_ref() } diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index bc0c98bac7..7913685b7a 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -1158,6 +1158,7 @@ pub struct InlineAssistantStyle { #[serde(flatten)] pub container: ContainerStyle, pub editor: FieldEditor, + pub disabled_editor: FieldEditor, pub pending_edit_background: Color, } diff --git a/styles/src/style_tree/assistant.ts b/styles/src/style_tree/assistant.ts index bdca8a16e5..8bef2ce16b 100644 --- a/styles/src/style_tree/assistant.ts +++ b/styles/src/style_tree/assistant.ts @@ -68,9 +68,17 @@ export default function assistant(): any { }), editor: { text: text(theme.highest, "mono", "default", { size: "sm" }), - placeholder_text: text(theme.lowest, "sans", "on", "disabled"), + placeholder_text: text(theme.highest, "sans", "on", "disabled"), selection: theme.players[0], }, + disabled_editor: { + text: text(theme.highest, "mono", "disabled", { size: "sm" }), + placeholder_text: text(theme.highest, "sans", "on", "disabled"), + selection: { + cursor: text(theme.highest, "mono", "disabled").color, + selection: theme.players[0].selection, + }, + }, pending_edit_background: background(theme.highest, "positive"), }, message_header: {