Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

assistant2: Fix submit button width depending on certain conditions (#25748)

Danilo Leal635b80ed51bb
diff --git a/Cargo.lock b/Cargo.lock
index 4e4cbf10b61..0a8b14ce4a4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -490,6 +490,7 @@ dependencies = [
"ui",
"util",
"uuid",
+ "vim_mode_setting",
"workspace",
"zed_actions",
]
diff --git a/crates/assistant2/Cargo.toml b/crates/assistant2/Cargo.toml
index 13116c2ab5f..cfa5fff5132 100644
--- a/crates/assistant2/Cargo.toml
+++ b/crates/assistant2/Cargo.toml
@@ -73,6 +73,7 @@ time_format.workspace = true
ui.workspace = true
util.workspace = true
uuid.workspace = true
+vim_mode_setting.workspace = true
workspace.workspace = true
zed_actions.workspace = true
diff --git a/crates/assistant2/src/message_editor.rs b/crates/assistant2/src/message_editor.rs
index 1051b3ea67e..0be0af53a4e 100644
--- a/crates/assistant2/src/message_editor.rs
+++ b/crates/assistant2/src/message_editor.rs
@@ -14,8 +14,10 @@ use std::time::Duration;
use text::Bias;
use theme::ThemeSettings;
use ui::{
- prelude::*, ButtonLike, KeyBinding, PopoverMenu, PopoverMenuHandle, Switch, TintColor, Tooltip,
+ prelude::*, ButtonLike, KeyBinding, PlatformStyle, PopoverMenu, PopoverMenuHandle, Switch,
+ TintColor, Tooltip,
};
+use vim_mode_setting::VimModeSetting;
use workspace::Workspace;
use crate::assistant_model_selector::AssistantModelSelector;
@@ -274,7 +276,6 @@ impl Render for MessageEditor {
let inline_context_picker = self.inline_context_picker.clone();
let bg_color = cx.theme().colors().editor_background;
let is_streaming_completion = self.thread.read(cx).is_streaming();
- let button_width = px(64.);
let is_model_selected = self.is_model_selected(cx);
let is_editor_empty = self.is_editor_empty(cx);
let submit_label_color = if is_editor_empty {
@@ -283,6 +284,16 @@ impl Render for MessageEditor {
Color::Default
};
+ let vim_mode_enabled = VimModeSetting::get_global(cx).0;
+ let platform = PlatformStyle::platform();
+ let linux = platform == PlatformStyle::Linux;
+ let windows = platform == PlatformStyle::Windows;
+ let button_width = if linux || windows || vim_mode_enabled {
+ px(92.)
+ } else {
+ px(64.)
+ };
+
v_flex()
.key_context("MessageEditor")
.on_action(cx.listener(Self::chat))