瀏覽代碼

Fix pasted text not being registered immediately

Input thread reading from stdin should continue reading after receiving
the magic BRACKET START sequence until receiving the BRACKET END
sequence.
Manos Pitsidianakis 5 年之前
父節點
當前提交
ca7bbd9de4
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      src/terminal/keys.rs

+ 8 - 2
src/terminal/keys.rs

@@ -175,10 +175,11 @@ pub fn get_events(
         select! {
         select! {
             default => {
             default => {
                 if stdin_fd.revents().is_some() {
                 if stdin_fd.revents().is_some() {
-                    if let Some(c) = stdin_iter.next(){
+                    'stdin_while: while let Some(c) = stdin_iter.next(){
                         match (c, &mut input_mode) {
                         match (c, &mut input_mode) {
                             (Ok((TermionEvent::Key(k), bytes)), InputMode::Normal) => {
                             (Ok((TermionEvent::Key(k), bytes)), InputMode::Normal) => {
                                 closure((Key::from(k), bytes));
                                 closure((Key::from(k), bytes));
+                                continue 'poll_while;
                             }
                             }
                             (
                             (
                                 Ok((TermionEvent::Key(TermionKey::Char(k)), ref mut bytes)), InputMode::Paste(ref mut buf),
                                 Ok((TermionEvent::Key(TermionKey::Char(k)), ref mut bytes)), InputMode::Paste(ref mut buf),
@@ -186,9 +187,11 @@ pub fn get_events(
                                 paste_buf.push(k);
                                 paste_buf.push(k);
                                 let bytes = std::mem::replace(bytes, Vec::new());
                                 let bytes = std::mem::replace(bytes, Vec::new());
                                 buf.extend(bytes.into_iter());
                                 buf.extend(bytes.into_iter());
+                                continue 'stdin_while;
                             }
                             }
                             (Ok((TermionEvent::Unsupported(ref k), _)), _) if k.as_slice() == BRACKET_PASTE_START => {
                             (Ok((TermionEvent::Unsupported(ref k), _)), _) if k.as_slice() == BRACKET_PASTE_START => {
                                 input_mode = InputMode::Paste(Vec::new());
                                 input_mode = InputMode::Paste(Vec::new());
+                                continue 'stdin_while;
                             }
                             }
                             (Ok((TermionEvent::Unsupported(ref k), _)), InputMode::Paste(ref mut buf))
                             (Ok((TermionEvent::Unsupported(ref k), _)), InputMode::Paste(ref mut buf))
                                 if k.as_slice() == BRACKET_PASTE_END =>
                                 if k.as_slice() == BRACKET_PASTE_END =>
@@ -198,8 +201,11 @@ pub fn get_events(
                                     let ret = Key::from(&paste_buf);
                                     let ret = Key::from(&paste_buf);
                                     paste_buf.clear();
                                     paste_buf.clear();
                                     closure((ret, buf));
                                     closure((ret, buf));
+                                    continue 'poll_while;
                                 }
                                 }
-                            _ => {} // Mouse events or errors.
+                            _ => {
+                                continue 'poll_while;
+                            } // Mouse events or errors.
                         }
                         }
                     }
                     }
                 }
                 }