aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-client
diff options
context:
space:
mode:
authorPierre Kisters <1524059+lhns@users.noreply.github.com>2026-07-17 15:24:52 +0200
committerGitHub <noreply@github.com>2026-07-17 15:24:52 +0200
commitd9682a2eef5ac0236808f05337f4f224bcf9d55f (patch)
treed0fc3b71324b4caa14ca99a89f0e07f74bd4a7fe /zellij-client
parentdocs(changelog): pane rename clear fix (diff)
downloadsl0ppij-d9682a2eef5ac0236808f05337f4f224bcf9d55f.tar.gz
sl0ppij-d9682a2eef5ac0236808f05337f4f224bcf9d55f.tar.xz
sl0ppij-d9682a2eef5ac0236808f05337f4f224bcf9d55f.zip
fix: input spam when moving mouse while typing by splitting the input bytes into their respective events (#5323)
Diffstat (limited to 'zellij-client')
-rw-r--r--zellij-client/src/stdin_handler.rs37
1 files changed, 19 insertions, 18 deletions
diff --git a/zellij-client/src/stdin_handler.rs b/zellij-client/src/stdin_handler.rs
index 535d9b67..29b7de7e 100644
--- a/zellij-client/src/stdin_handler.rs
+++ b/zellij-client/src/stdin_handler.rs
@@ -177,11 +177,11 @@ pub(crate) fn stdin_loop(
// Ambiguous events (if any) will be finalized later only if 50ms
// passes with no new input
let maybe_more = true;
- let mut events = vec![];
- input_parser.parse(
+ let mut events: Vec<(InputEvent, usize)> = vec![];
+ input_parser.parse_with_consumed(
&residue,
- |input_event: InputEvent| {
- events.push(input_event);
+ |input_event: InputEvent, consumed: usize| {
+ events.push((input_event, consumed));
},
maybe_more,
);
@@ -190,12 +190,14 @@ pub(crate) fn stdin_loop(
// reports — `StdinAnsiParser::feed` strips both
// before the keyboard parser sees the bytes.
// Every termwiz event is a key/mouse/paste/etc.
- for input_event in events.into_iter() {
+ // Each event is forwarded with exactly the bytes
+ // that produced it, never bytes belonging to other
+ // events decoded from the same read.
+ for (input_event, consumed) in events.into_iter() {
+ let take = consumed.min(current_buffer.len());
+ let raw_bytes: Vec<u8> = current_buffer.drain(..take).collect();
send_input_instructions
- .send(InputInstruction::KeyEvent(
- input_event,
- current_buffer.drain(..).collect(),
- ))
+ .send(InputInstruction::KeyEvent(input_event, raw_bytes))
.unwrap();
}
@@ -289,20 +291,19 @@ fn drain_partial_to_keyboard(
current_buffer.extend_from_slice(&drained);
}
- let mut events = vec![];
- input_parser.parse(
+ let mut events: Vec<(InputEvent, usize)> = vec![];
+ input_parser.parse_with_consumed(
&drained,
- |input_event: InputEvent| {
- events.push(input_event);
+ |input_event: InputEvent, consumed: usize| {
+ events.push((input_event, consumed));
},
false,
);
- for input_event in events {
+ for (input_event, consumed) in events {
+ let take = consumed.min(current_buffer.len());
+ let raw_bytes: Vec<u8> = current_buffer.drain(..take).collect();
send_input_instructions
- .send(InputInstruction::KeyEvent(
- input_event,
- current_buffer.drain(..).collect(),
- ))
+ .send(InputInstruction::KeyEvent(input_event, raw_bytes))
.unwrap();
}
}