Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 40 additions & 9 deletions crates/ui/src/composer/components/trigger_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ impl Composer {
/// highlight (and un-dismissing) when the trigger identity changes, and
/// lazily loading the workspace listing for `@`-mentions.
pub(in super::super) fn recompute_trigger(&mut self, cx: &mut Context<Self>) {
if self.compact {
self.active_trigger = None;
return;
}
let (text, cursor) = {
let state = self.input.read(cx);
(state.value().to_string(), state.cursor())
Expand Down Expand Up @@ -411,10 +407,16 @@ fn render_menu_row(
#[cfg(test)]
mod tests {
use super::*;
use gpui::{TestAppContext, size};
use gpui::{TestAppContext, VisualTestContext, size};

#[gpui::test]
fn arrow_keys_keep_the_highlighted_mention_laid_out(cx: &mut TestAppContext) {
fn composer_window(
compact: bool,
cx: &mut TestAppContext,
) -> (
Entity<WorkspaceStore>,
Entity<Composer>,
&mut VisualTestContext,
) {
cx.update(crate::theme::init);
let host = tcode_runtime::pipe::spawn_host(
tcode_services::store::SessionStore::open_at(std::env::temp_dir().join(format!(
Expand All @@ -436,8 +438,37 @@ mod tests {
store.update(cx, |store, cx| {
store.set_session_replica_for_test(session_id, timeline, cx);
});
let (composer, cx) =
cx.add_window_view(|window, cx| Composer::new(store.clone(), window, cx));
let (composer, cx) = cx.add_window_view(|window, cx| {
Composer::new_with_layout(store.clone(), compact, window, cx)
});
(store, composer, cx)
}

#[gpui::test]
fn the_phone_composer_opens_the_same_trigger_menus(cx: &mut TestAppContext) {
let (store, composer, cx) = composer_window(true, cx);
cx.simulate_resize(size(px(393.), px(852.)));
composer.update_in(cx, |composer, window, cx| {
let cwd = store.read(cx).composer_state().active_cwd.unwrap();
composer.workspace = Some((cwd, vec![PathEntry::from_rel("file.rs".into(), false)]));
window.focus(&composer.input.read(cx).focus_handle(cx), cx);
});
for (trigger, first_row) in [("/", "/model"), ("@", "file.rs")] {
composer.update_in(cx, |composer, window, cx| {
composer.set_draft("", window, cx)
});
cx.simulate_input(trigger);
cx.update(|window, cx| _ = window.draw(cx));
assert!(cx.debug_bounds("menu-row-0").is_some(), "{trigger}");
composer.read_with(cx, |composer, cx| {
assert_eq!(composer.menu_rows(cx).0[0].primary, first_row, "{trigger}");
});
}
}

#[gpui::test]
fn arrow_keys_keep_the_highlighted_mention_laid_out(cx: &mut TestAppContext) {
let (store, composer, cx) = composer_window(false, cx);
cx.simulate_resize(size(px(800.), px(600.)));
composer.update_in(cx, |composer, window, cx| {
let cwd = store.read(cx).composer_state().active_cwd.unwrap();
Expand Down
3 changes: 1 addition & 2 deletions crates/ui/src/composer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,7 @@ impl Composer {
window.push_notification(Notification::info(crate::tr!("composer.no_session")), cx);
return;
}
if !self.compact
&& terminal_contexts.is_empty()
if terminal_contexts.is_empty()
&& let Some(later) = parse_later(&text, Local::now())
{
let Ok((fire_at_unix_secs, message)) = later else {
Expand Down
Loading