Add disabled style for prompt editor after confirming

This commit is contained in:
Antonio Scandurra 2023-08-26 12:07:03 +02:00
parent 658d616b96
commit 55bf45d265
4 changed files with 28 additions and 3 deletions

View file

@ -2871,8 +2871,15 @@ impl InlineAssistant {
cx.emit(InlineAssistantEvent::Dismissed); cx.emit(InlineAssistantEvent::Dismissed);
} else { } else {
let prompt = self.prompt_editor.read(cx).text(cx); let prompt = self.prompt_editor.read(cx).text(cx);
self.prompt_editor self.prompt_editor.update(cx, |editor, cx| {
.update(cx, |editor, _| editor.set_read_only(true)); 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 }); cx.emit(InlineAssistantEvent::Confirmed { prompt });
self.confirmed = true; self.confirmed = true;
} }

View file

@ -1606,6 +1606,15 @@ impl Editor {
self.read_only = read_only; self.read_only = read_only;
} }
pub fn set_field_editor_style(
&mut self,
style: Option<Arc<GetFieldEditorTheme>>,
cx: &mut ViewContext<Self>,
) {
self.get_field_editor_theme = style;
cx.notify();
}
pub fn replica_id_map(&self) -> Option<&HashMap<ReplicaId, ReplicaId>> { pub fn replica_id_map(&self) -> Option<&HashMap<ReplicaId, ReplicaId>> {
self.replica_id_mapping.as_ref() self.replica_id_mapping.as_ref()
} }

View file

@ -1158,6 +1158,7 @@ pub struct InlineAssistantStyle {
#[serde(flatten)] #[serde(flatten)]
pub container: ContainerStyle, pub container: ContainerStyle,
pub editor: FieldEditor, pub editor: FieldEditor,
pub disabled_editor: FieldEditor,
pub pending_edit_background: Color, pub pending_edit_background: Color,
} }

View file

@ -68,9 +68,17 @@ export default function assistant(): any {
}), }),
editor: { editor: {
text: text(theme.highest, "mono", "default", { size: "sm" }), 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], 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"), pending_edit_background: background(theme.highest, "positive"),
}, },
message_header: { message_header: {