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.
This commit is contained in:
parent
bded92f553
commit
c2453b471b
1 changed files with 14 additions and 6 deletions
|
|
@ -14,12 +14,21 @@ pub(crate) fn stdin_loop(
|
||||||
let buf = os_input.read_from_stdin();
|
let buf = os_input.read_from_stdin();
|
||||||
current_buffer.append(&mut buf.to_vec());
|
current_buffer.append(&mut buf.to_vec());
|
||||||
let maybe_more = false; // read_from_stdin should (hopefully) always empty the STDIN buffer completely
|
let maybe_more = false; // read_from_stdin should (hopefully) always empty the STDIN buffer completely
|
||||||
let parse_input_event = |input_event: InputEvent| {
|
let mut events = vec![];
|
||||||
if holding_mouse && is_mouse_press_or_hold(&input_event) {
|
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();
|
let mut poller = os_input.stdin_poller();
|
||||||
loop {
|
loop {
|
||||||
let ready = poller.ready();
|
if poller.ready() {
|
||||||
if ready {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
send_input_instructions
|
send_input_instructions
|
||||||
|
|
@ -39,8 +48,7 @@ pub(crate) fn stdin_loop(
|
||||||
current_buffer.drain(..).collect(),
|
current_buffer.drain(..).collect(),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
};
|
}
|
||||||
input_parser.parse(&buf, parse_input_event, maybe_more);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue