Pause and buffer
This commit is contained in:
parent
86406153bd
commit
bb8263104c
3 changed files with 23 additions and 17 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -5368,6 +5368,7 @@ dependencies = [
|
||||||
"settings",
|
"settings",
|
||||||
"shellexpand",
|
"shellexpand",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
|
"smol",
|
||||||
"theme",
|
"theme",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"util",
|
"util",
|
||||||
|
|
|
@ -17,6 +17,7 @@ settings = { path = "../settings" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
project = { path = "../project" }
|
project = { path = "../project" }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { version = "1.6", features = ["union"] }
|
||||||
|
smol = "1.2.5"
|
||||||
mio-extras = "2.0.6"
|
mio-extras = "2.0.6"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
ordered-float = "2.1.1"
|
ordered-float = "2.1.1"
|
||||||
|
|
|
@ -19,10 +19,7 @@ use alacritty_terminal::{
|
||||||
};
|
};
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
|
|
||||||
use futures::{
|
use futures::channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender};
|
||||||
channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
|
|
||||||
future,
|
|
||||||
};
|
|
||||||
|
|
||||||
use modal::deploy_modal;
|
use modal::deploy_modal;
|
||||||
use settings::{Settings, Shell};
|
use settings::{Settings, Shell};
|
||||||
|
@ -350,25 +347,32 @@ impl TerminalBuilder {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn subscribe(self, cx: &mut ModelContext<Terminal>) -> Terminal {
|
pub fn subscribe(mut self, cx: &mut ModelContext<Terminal>) -> Terminal {
|
||||||
//Event loop
|
//Event loop
|
||||||
cx.spawn_weak(|this, mut cx| async move {
|
cx.spawn_weak(|this, mut cx| async move {
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
|
|
||||||
self.events_rx
|
let mut events = Vec::new();
|
||||||
.for_each(|event| {
|
while let Some(event) = self.events_rx.next().await {
|
||||||
match this.upgrade(&cx) {
|
events.push(event);
|
||||||
Some(this) => {
|
while let Ok(Some(event)) = self.events_rx.try_next() {
|
||||||
this.update(&mut cx, |this, cx| {
|
events.push(event);
|
||||||
this.process_event(&event, cx);
|
if events.len() > 1000 {
|
||||||
});
|
break;
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
future::ready(())
|
let this = this.upgrade(&cx)?;
|
||||||
})
|
this.update(&mut cx, |this, cx| {
|
||||||
.await;
|
for event in events.drain(..) {
|
||||||
|
this.process_event(&event, cx);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
smol::future::yield_now().await;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(())
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue