fix(tui): let mouse capture keep history arrows on Windows (#1720)

* fix(tui): let mouse capture keep history arrows on Windows

* test(tui): update arrow-scroll mouse capture expectation
This commit is contained in:
Hunter Bown
2026-05-26 10:06:51 -05:00
committed by GitHub
parent 1763261503
commit b3c50e0c90
3 changed files with 16 additions and 12 deletions
+3 -3
View File
@@ -500,9 +500,9 @@ pub struct TuiConfig {
/// - Unset (default) — fall back to the `[notifications]` defaults.
pub notification_condition: Option<NotificationCondition>,
/// When `true`, plain Up/Down on an empty composer scroll the
/// transcript instead of recalling input history. Useful for
/// terminals that map trackpad gestures to arrow keys. Default:
/// `false` (plain arrows always navigate input history, #1117).
/// transcript instead of recalling input history. Useful for
/// terminals that map mouse-wheel gestures to arrow keys. Default:
/// `true` only when mouse capture is off; otherwise `false`.
#[serde(default)]
pub composer_arrows_scroll: Option<bool>,
}
+9 -4
View File
@@ -1561,8 +1561,8 @@ fn default_composer_arrows_scroll(use_mouse_capture: bool) -> bool {
default_composer_arrows_scroll_for_platform(use_mouse_capture, cfg!(windows))
}
fn default_composer_arrows_scroll_for_platform(use_mouse_capture: bool, is_windows: bool) -> bool {
is_windows || !use_mouse_capture
fn default_composer_arrows_scroll_for_platform(use_mouse_capture: bool, _is_windows: bool) -> bool {
!use_mouse_capture
}
impl App {
@@ -4735,8 +4735,13 @@ mod tests {
}
#[test]
fn composer_arrows_scroll_default_is_true_on_windows_even_with_mouse_capture() {
assert!(default_composer_arrows_scroll_for_platform(true, true));
fn composer_arrows_scroll_default_is_false_with_mouse_capture_on_windows() {
assert!(!default_composer_arrows_scroll_for_platform(true, true));
}
#[test]
fn composer_arrows_scroll_default_is_true_without_mouse_capture_on_windows() {
assert!(default_composer_arrows_scroll_for_platform(false, true));
}
#[test]
+4 -5
View File
@@ -5972,16 +5972,15 @@ fn composer_arrows_scroll_defaults_true_without_mouse_capture() {
}
#[test]
fn composer_arrows_scroll_defaults_follow_platform_with_mouse_capture() {
fn composer_arrows_scroll_defaults_false_with_mouse_capture() {
let options = TuiOptions {
use_mouse_capture: true,
..create_test_options()
};
let app = App::new(options, &Config::default());
assert_eq!(
app.composer_arrows_scroll,
cfg!(windows),
"arrows-scroll should default to true on Windows and false on other platforms when mouse capture is on"
assert!(
!app.composer_arrows_scroll,
"arrows-scroll must default to false when mouse capture is on"
);
}