Skip to content

Commit a8c7e61

Browse files
Fix AI Context menu text wrapping causing overlap (#21438)
Closes #20678 | Before | After | | --- | --- | | <img width="672" alt="SCR-20241203-jreb" src="https://github.com/user-attachments/assets/411ba2a6-712f-4ab7-a320-12ac9a35c1e1"> | <img width="771" alt="SCR-20241203-jwhe" src="https://github.com/user-attachments/assets/022c8ee9-4089-4c09-aa4b-12a0f5528822"> | Release Notes: - Fixed AI Context menu text wrapping causing overlap. Also cc #21409 @WeetHet @osiewicz to use `Label`, this PR has been fixed `Label` to ensure `whitespace_nowrap` when use `single_line`. --------- Co-authored-by: Danilo Leal <[email protected]>
1 parent 2b14378 commit a8c7e61

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

crates/assistant/src/slash_command_picker.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::sync::Arc;
22

33
use gpui::{AnyElement, DismissEvent, SharedString, Task, WeakView};
44
use picker::{Picker, PickerDelegate, PickerEditorPosition};
5-
use ui::{prelude::*, ListItem, ListItemSpacing, PopoverMenu, PopoverTrigger};
5+
use ui::{prelude::*, ListItem, ListItemSpacing, PopoverMenu, PopoverTrigger, Tooltip};
66

77
use crate::assistant_panel::ContextEditor;
88
use crate::SlashCommandWorkingSet;
@@ -177,11 +177,17 @@ impl PickerDelegate for SlashCommandDelegate {
177177
.inset(true)
178178
.spacing(ListItemSpacing::Dense)
179179
.selected(selected)
180+
.tooltip({
181+
let description = info.description.clone();
182+
move |cx| cx.new_view(|_| Tooltip::new(description.clone())).into()
183+
})
180184
.child(
181185
v_flex()
182186
.group(format!("command-entry-label-{ix}"))
183187
.w_full()
188+
.py_0p5()
184189
.min_w(px(250.))
190+
.max_w(px(400.))
185191
.child(
186192
h_flex()
187193
.gap_1p5()
@@ -192,14 +198,15 @@ impl PickerDelegate for SlashCommandDelegate {
192198
{
193199
label.push_str(&args);
194200
}
195-
Label::new(label).size(LabelSize::Small)
201+
Label::new(label).single_line().size(LabelSize::Small)
196202
}))
197203
.children(info.args.clone().filter(|_| !selected).map(
198204
|args| {
199205
div()
200206
.font_buffer(cx)
201207
.child(
202208
Label::new(args)
209+
.single_line()
203210
.size(LabelSize::Small)
204211
.color(Color::Muted),
205212
)
@@ -210,9 +217,11 @@ impl PickerDelegate for SlashCommandDelegate {
210217
)),
211218
)
212219
.child(
213-
Label::new(info.description.clone())
214-
.size(LabelSize::Small)
215-
.color(Color::Muted),
220+
div().overflow_hidden().text_ellipsis().child(
221+
Label::new(info.description.clone())
222+
.size(LabelSize::Small)
223+
.color(Color::Muted),
224+
),
216225
),
217226
),
218227
),

0 commit comments

Comments
 (0)