agent: Improve layout shift on previous message editor (#33055)
Follow up to https://github.com/zed-industries/zed/pull/32765. This PR creates a slot for the `message_editor::create_editor` to allow using different values for min and max lines. In practice, the panel's main editor now has a minimum of 4 lines, whereas the previous message editor has just one. This makes the layout shift when clicking on a previous message to edit it much smaller. Release Notes: - agent: Improved layout shift when clicking to edit a previous sent message.
This commit is contained in:
parent
5c7e90d494
commit
b89ddf3a6e
2 changed files with 12 additions and 4 deletions
|
@ -57,6 +57,10 @@ use workspace::{CollaboratorId, Workspace};
|
||||||
use zed_actions::assistant::OpenRulesLibrary;
|
use zed_actions::assistant::OpenRulesLibrary;
|
||||||
use zed_llm_client::CompletionIntent;
|
use zed_llm_client::CompletionIntent;
|
||||||
|
|
||||||
|
const CODEBLOCK_CONTAINER_GROUP: &str = "codeblock_container";
|
||||||
|
const EDIT_PREVIOUS_MESSAGE_MIN_LINES: usize = 1;
|
||||||
|
const EDIT_PREVIOUS_MESSAGE_MAX_LINES: usize = 6;
|
||||||
|
|
||||||
pub struct ActiveThread {
|
pub struct ActiveThread {
|
||||||
context_store: Entity<ContextStore>,
|
context_store: Entity<ContextStore>,
|
||||||
language_registry: Arc<LanguageRegistry>,
|
language_registry: Arc<LanguageRegistry>,
|
||||||
|
@ -334,8 +338,6 @@ fn tool_use_markdown_style(window: &Window, cx: &mut App) -> MarkdownStyle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CODEBLOCK_CONTAINER_GROUP: &str = "codeblock_container";
|
|
||||||
|
|
||||||
fn render_markdown_code_block(
|
fn render_markdown_code_block(
|
||||||
message_id: MessageId,
|
message_id: MessageId,
|
||||||
ix: usize,
|
ix: usize,
|
||||||
|
@ -1327,6 +1329,8 @@ impl ActiveThread {
|
||||||
self.context_store.downgrade(),
|
self.context_store.downgrade(),
|
||||||
self.thread_store.downgrade(),
|
self.thread_store.downgrade(),
|
||||||
self.text_thread_store.downgrade(),
|
self.text_thread_store.downgrade(),
|
||||||
|
EDIT_PREVIOUS_MESSAGE_MIN_LINES,
|
||||||
|
EDIT_PREVIOUS_MESSAGE_MAX_LINES,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
|
@ -89,6 +89,8 @@ pub(crate) fn create_editor(
|
||||||
context_store: WeakEntity<ContextStore>,
|
context_store: WeakEntity<ContextStore>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
thread_store: WeakEntity<ThreadStore>,
|
||||||
text_thread_store: WeakEntity<TextThreadStore>,
|
text_thread_store: WeakEntity<TextThreadStore>,
|
||||||
|
min_lines: usize,
|
||||||
|
max_lines: usize,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Entity<Editor> {
|
) -> Entity<Editor> {
|
||||||
|
@ -105,8 +107,8 @@ pub(crate) fn create_editor(
|
||||||
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
|
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
|
||||||
let mut editor = Editor::new(
|
let mut editor = Editor::new(
|
||||||
editor::EditorMode::AutoHeight {
|
editor::EditorMode::AutoHeight {
|
||||||
min_lines: MIN_EDITOR_LINES,
|
min_lines,
|
||||||
max_lines: MAX_EDITOR_LINES,
|
max_lines,
|
||||||
},
|
},
|
||||||
buffer,
|
buffer,
|
||||||
None,
|
None,
|
||||||
|
@ -161,6 +163,8 @@ impl MessageEditor {
|
||||||
context_store.downgrade(),
|
context_store.downgrade(),
|
||||||
thread_store.clone(),
|
thread_store.clone(),
|
||||||
text_thread_store.clone(),
|
text_thread_store.clone(),
|
||||||
|
MIN_EDITOR_LINES,
|
||||||
|
MAX_EDITOR_LINES,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue