diff options
author | Thomas Linford <tlinford@users.noreply.github.com> | 2022-06-06 12:06:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-06 12:06:48 +0200 |
commit | c2453b471b3f22603c388494e7fe67ce1f7ee77f (patch) | |
tree | d2dc2961546507a29a63a1560b5df1dbd1966090 /zellij-client/src | |
parent | bded92f5537bc6d91b447d7c161b6d3f46cbd8bc (diff) |
fix(mouse): selection sometimes getting stuck (#1418)
- when multiple mouse events are read from stdin,
start mouse hold repeat loop only if hold event is the last.
Diffstat (limited to 'zellij-client/src')
-rw-r--r-- | zellij-client/src/stdin_handler.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/zellij-client/src/stdin_handler.rs b/zellij-client/src/stdin_handler.rs index e6794dedb..687ecd108 100644 --- a/zellij-client/src/stdin_handler.rs +++ b/zellij-client/src/stdin_handler.rs @@ -14,12 +14,21 @@ pub(crate) fn stdin_loop( let buf = os_input.read_from_stdin(); current_buffer.append(&mut buf.to_vec()); let maybe_more = false; // read_from_stdin should (hopefully) always empty the STDIN buffer completely - let parse_input_event = |input_event: InputEvent| { - if holding_mouse && is_mouse_press_or_hold(&input_event) { + let mut events = vec![]; + input_parser.parse( + &buf, + |input_event: InputEvent| { + events.push(input_event); + }, + maybe_more, + ); + + let event_count = events.len(); + for (i, input_event) in events.into_iter().enumerate() { + if holding_mouse && is_mouse_press_or_hold(&input_event) && i == event_count - 1 { let mut poller = os_input.stdin_poller(); loop { - let ready = poller.ready(); - if ready { + if poller.ready() { break; } send_input_instructions @@ -39,8 +48,7 @@ pub(crate) fn stdin_loop( current_buffer.drain(..).collect(), )) .unwrap(); - }; - input_parser.parse(&buf, parse_input_event, maybe_more); + } } } |