aboutsummaryrefslogtreecommitdiff
path: root/src/pane
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-07 17:01:27 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-07 17:01:27 +0300
commit3f7236f81735e338e2ed3ecbf0f1fed26392acba (patch)
tree779d74b0242e3916273ed9b27248342d9dfdad2d /src/pane
parent7c7d8c8619006b25244bcdac0abc560cd43108ab (diff)
fix: drop empty pty mouse writes
refs #496
Diffstat (limited to 'src/pane')
-rw-r--r--src/pane/terminal.rs32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/pane/terminal.rs b/src/pane/terminal.rs
index 9bfcf57f..5f44854d 100644
--- a/src/pane/terminal.rs
+++ b/src/pane/terminal.rs
@@ -923,7 +923,10 @@ impl GhosttyPaneTerminal {
};
let mut encoder = ghostty_mouse_encoder_for_terminal(&core.terminal)?;
let event = ghostty_mouse_event_from_button_kind(kind, column, row, modifiers)?;
- encoder.encode(&event).ok()
+ encoder
+ .encode(&event)
+ .ok()
+ .filter(|bytes| !bytes.is_empty())
}
pub fn encode_mouse_motion(
@@ -941,7 +944,10 @@ impl GhosttyPaneTerminal {
}
let mut encoder = ghostty_mouse_encoder_for_terminal(&core.terminal)?;
let event = ghostty_mouse_event_from_motion_kind(kind, column, row, modifiers)?;
- encoder.encode(&event).ok()
+ encoder
+ .encode(&event)
+ .ok()
+ .filter(|bytes| !bytes.is_empty())
}
pub fn encode_mouse_wheel(
@@ -956,7 +962,10 @@ impl GhosttyPaneTerminal {
};
let mut encoder = ghostty_mouse_encoder_for_terminal(&core.terminal)?;
let event = ghostty_mouse_event_from_wheel_kind(kind, column, row, modifiers)?;
- encoder.encode(&event).ok()
+ encoder
+ .encode(&event)
+ .ok()
+ .filter(|bytes| !bytes.is_empty())
}
pub fn visible_text(&self) -> String {
@@ -2411,6 +2420,23 @@ mod tests {
}
#[test]
+ fn ghostty_mouse_drag_without_motion_reporting_is_not_forwarded() {
+ let (tx, _rx) = mpsc::channel(4);
+ let mut terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap();
+ terminal.write(b"\x1b[?1000h\x1b[?1006h");
+ let pane = GhosttyPaneTerminal::new(terminal, tx).unwrap();
+
+ let encoded = pane.encode_mouse_button(
+ crossterm::event::MouseEventKind::Drag(crossterm::event::MouseButton::Left),
+ 4,
+ 6,
+ crossterm::event::KeyModifiers::empty(),
+ );
+
+ assert_eq!(encoded, None);
+ }
+
+ #[test]
fn ghostty_mouse_moved_encoding_uses_any_motion_state() {
let (tx, _rx) = mpsc::channel(4);
let mut terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap();