Strip mouse reports unless a TUI owns them
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / publish-gitea-release (push) Blocked by required conditions
ci / remote-bench (push) Waiting to run
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / publish-gitea-release (push) Blocked by required conditions
ci / remote-bench (push) Waiting to run
This commit is contained in:
+18
-9
@@ -7434,7 +7434,10 @@ fn should_reconnect_before_input_for_local_sleep(
|
||||
}
|
||||
|
||||
fn should_strip_unowned_terminal_reports(alternate_screen: bool, mouse_tracking: bool) -> bool {
|
||||
!alternate_screen && !mouse_tracking
|
||||
// Only a full-screen app that explicitly enabled mouse reporting owns these
|
||||
// bytes. In every other state, local terminal mouse reports are stale UI
|
||||
// noise and forwarding them can type SGR fragments at a normal shell prompt.
|
||||
!(alternate_screen && mouse_tracking)
|
||||
}
|
||||
|
||||
fn strip_unowned_terminal_reports(
|
||||
@@ -10257,10 +10260,11 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unowned_mouse_reports_are_stripped_only_outside_terminal_mouse_mode() {
|
||||
fn unowned_mouse_reports_are_stripped_unless_tui_owns_mouse() {
|
||||
assert!(should_strip_unowned_terminal_reports(false, false));
|
||||
assert!(!should_strip_unowned_terminal_reports(false, true));
|
||||
assert!(!should_strip_unowned_terminal_reports(true, false));
|
||||
assert!(should_strip_unowned_terminal_reports(false, true));
|
||||
assert!(should_strip_unowned_terminal_reports(true, false));
|
||||
assert!(!should_strip_unowned_terminal_reports(true, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -11549,19 +11553,24 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unowned_terminal_mouse_reports_strip_only_without_mouse_owner() {
|
||||
fn unowned_terminal_mouse_reports_strip_unless_tui_owns_mouse() {
|
||||
let input = b"\x1b[<35;10;1Mcmd\r".to_vec();
|
||||
|
||||
let (stripped, changed) = strip_unowned_terminal_reports(input.clone(), false, false);
|
||||
assert!(changed);
|
||||
assert_eq!(stripped, b"cmd\r");
|
||||
|
||||
let (preserved, changed) = strip_unowned_terminal_reports(input.clone(), false, true);
|
||||
assert!(!changed);
|
||||
assert_eq!(preserved, input);
|
||||
let (stripped, changed) = strip_unowned_terminal_reports(input.clone(), false, true);
|
||||
assert!(changed);
|
||||
assert_eq!(stripped, b"cmd\r");
|
||||
|
||||
let (stripped, changed) =
|
||||
strip_unowned_terminal_reports(b"\x1b[<35;10;1M".to_vec(), true, false);
|
||||
assert!(changed);
|
||||
assert!(stripped.is_empty());
|
||||
|
||||
let (preserved, changed) =
|
||||
strip_unowned_terminal_reports(b"\x1b[<35;10;1M".to_vec(), true, false);
|
||||
strip_unowned_terminal_reports(b"\x1b[<35;10;1M".to_vec(), true, true);
|
||||
assert!(!changed);
|
||||
assert_eq!(preserved, b"\x1b[<35;10;1M");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user