update en el momento correcto
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs::read_dir,
|
fs::read_dir,
|
||||||
io::stdout,
|
io::stdout,
|
||||||
|
os::unix::process,
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
thread::sleep,
|
thread::sleep,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
@@ -61,14 +62,21 @@ pub fn run() {
|
|||||||
|
|
||||||
let mut search_thread = test(list.clone(), input.clone(), results.clone());
|
let mut search_thread = test(list.clone(), input.clone(), results.clone());
|
||||||
|
|
||||||
|
// let mut new_input = true;
|
||||||
|
|
||||||
|
let mut processing = false;
|
||||||
|
|
||||||
let mut last_input = String::new();
|
let mut last_input = String::new();
|
||||||
|
|
||||||
while cont.read().unwrap().to_owned() {
|
while cont.read().unwrap().to_owned() {
|
||||||
let input_buff = input.read().unwrap().0.clone();
|
let input_buff = input.read().unwrap().0.clone();
|
||||||
if String::from_iter(input.read().unwrap().clone().0).as_str() != last_input.as_str()
|
if String::from_iter(input.read().unwrap().clone().0).as_str() != last_input.as_str() {
|
||||||
&& search_thread.is_finished()
|
|
||||||
{
|
|
||||||
search_thread = test(list.clone(), input.clone(), results.clone());
|
search_thread = test(list.clone(), input.clone(), results.clone());
|
||||||
|
// new_input = false;
|
||||||
|
processing = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if processing && search_thread.is_finished() {
|
||||||
let res_list = results.read().unwrap();
|
let res_list = results.read().unwrap();
|
||||||
for (i, res) in res_list[0..(size.1 as usize - 4).min(res_list.len())]
|
for (i, res) in res_list[0..(size.1 as usize - 4).min(res_list.len())]
|
||||||
.iter()
|
.iter()
|
||||||
@@ -93,8 +101,8 @@ pub fn run() {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
execute!(stdout()).unwrap();
|
execute!(stdout()).unwrap();
|
||||||
sleep(Duration::from_millis(1));
|
|
||||||
last_input = String::from_iter(input_buff);
|
last_input = String::from_iter(input_buff);
|
||||||
|
sleep(Duration::from_millis(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user