Fixed session end buttons
This commit is contained in:
1 parent
a85c57c8e7
commit
ce917ced9f
3 files changed
+188
-47
No files matched your search
+54
-1
@@ -11889,6 +11889,9 @@ impl canvas::Program<Message> for TerminalCanvas<'_> {
|
||||
)))
|
||||
}
|
||||
canvas::Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left)) => {
|
||||
if !*dragging {
|
||||
return None;
|
||||
}
|
||||
*dragging = false;
|
||||
Some(canvas::Action::capture())
|
||||
}
|
||||
@@ -12194,7 +12197,9 @@ fn terminal_page<'a>(state: &'a Moorly, window: window::Id, id: u32) -> Element<
|
||||
text_color: Some(theme.foreground),
|
||||
..container::Style::default()
|
||||
})
|
||||
];
|
||||
]
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill);
|
||||
|
||||
if let Some(exit) = terminal_session.exit {
|
||||
let status = match (exit.code, exit.signal) {
|
||||
@@ -15485,6 +15490,54 @@ start_path = "/tmp"
|
||||
state.terminal_sessions.clear();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kept_terminal_footer_buttons_restart_and_close() {
|
||||
use super::terminal::ExitInfo;
|
||||
|
||||
let ended = || ExitInfo {
|
||||
code: Some(0),
|
||||
signal: None,
|
||||
};
|
||||
|
||||
let (mut state, window, id) = terminal_for_session_end(super::SessionEnd::Keep);
|
||||
state.terminal_sessions.get_mut(&id).unwrap().exit = Some(ended());
|
||||
|
||||
let _ = update(&mut state, Message::RestartTerminal(id));
|
||||
assert!(state.terminal_sessions[&id].exit.is_none());
|
||||
assert!(state.windows[&window].tabs.contains(&Tab::Terminal(id)));
|
||||
|
||||
state.terminal_sessions.get_mut(&id).unwrap().exit = Some(ended());
|
||||
let _ = update(&mut state, Message::CloseTab(window, Tab::Terminal(id)));
|
||||
assert!(
|
||||
state
|
||||
.windows
|
||||
.get(&window)
|
||||
.is_none_or(|window| !window.tabs.contains(&Tab::Terminal(id)))
|
||||
);
|
||||
assert!(!state.terminal_sessions.contains_key(&id));
|
||||
|
||||
state.terminal_sessions.clear();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kept_terminal_footer_buttons_are_clickable() {
|
||||
use super::terminal::ExitInfo;
|
||||
|
||||
let (mut state, window, id) = terminal_for_session_end(super::SessionEnd::Keep);
|
||||
state.terminal_sessions.get_mut(&id).unwrap().exit = Some(ExitInfo {
|
||||
code: Some(0),
|
||||
signal: None,
|
||||
});
|
||||
|
||||
let mut ui = iced_test::simulator(super::terminal_page(&state, window, id));
|
||||
ui.click("Close").unwrap();
|
||||
|
||||
assert!(
|
||||
ui.into_messages()
|
||||
.any(|message| matches!(message, Message::CloseTab(_, Tab::Terminal(_))))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn running_a_terminal_profile_opens_and_closes_a_session() {
|
||||
let mut state = state();
|
||||
|
||||
Reference in new issue
Block a user