Move await outside of a closure, remove future_wrap dependency
This commit is contained in:
parent
172e276411
commit
2b0b341415
4 changed files with 10 additions and 33 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -1950,15 +1950,6 @@ version = "0.3.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
|
||||
|
||||
[[package]]
|
||||
name = "future-wrap"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bab12b2506593396c1339caf22beeb6f5cbe95dac5e376b71a3d17cbe2c4630"
|
||||
dependencies = [
|
||||
"pin-project",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.21"
|
||||
|
@ -7018,7 +7009,6 @@ dependencies = [
|
|||
"env_logger",
|
||||
"file_finder",
|
||||
"fsevent",
|
||||
"future-wrap",
|
||||
"futures",
|
||||
"fuzzy",
|
||||
"go_to_line",
|
||||
|
|
|
@ -1732,8 +1732,9 @@ impl Project {
|
|||
.await?;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.assign_language_to_buffer(&buffer, cx);
|
||||
this.register_buffer_with_language_server(&buffer, cx).await;
|
||||
});
|
||||
this.register_buffer_with_language_server(&buffer, cx)
|
||||
})
|
||||
.await;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
@ -1791,6 +1792,7 @@ impl Project {
|
|||
.detach();
|
||||
|
||||
self.assign_language_to_buffer(buffer, cx);
|
||||
// TODO(isaac): should this be done in the background
|
||||
self.register_buffer_with_language_server(buffer, cx).await;
|
||||
cx.observe_release(buffer, |this, buffer, cx| {
|
||||
if let Some(file) = File::from_dyn(buffer.file()) {
|
||||
|
|
|
@ -102,8 +102,6 @@ tree-sitter-toml = { git = "https://github.com/tree-sitter/tree-sitter-toml", re
|
|||
tree-sitter-typescript = "0.20.1"
|
||||
url = "2.2"
|
||||
|
||||
# TODO(isaac): remove this
|
||||
future-wrap = "0.1.1"
|
||||
|
||||
[dev-dependencies]
|
||||
text = { path = "../text", features = ["test-support"] }
|
||||
|
|
|
@ -9,31 +9,18 @@ use plugin_runtime::{Plugin, PluginBuilder, WasiFn};
|
|||
use std::{any::Any, path::PathBuf, sync::Arc};
|
||||
use util::ResultExt;
|
||||
|
||||
use future_wrap::*;
|
||||
|
||||
pub async fn new_json(executor: Arc<Background>) -> Result<PluginLspAdapter> {
|
||||
let plugin = PluginBuilder::new_with_default_ctx()?
|
||||
.host_function_async("command", |command: String| async move {
|
||||
dbg!(&command);
|
||||
|
||||
// TODO: actual thing
|
||||
let mut args = command.split(' ');
|
||||
let command = args.next().unwrap();
|
||||
|
||||
dbg!("Running external command");
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
let future = smol::process::Command::new(command).args(args).output();
|
||||
let future = future.wrap(|fut, cx| {
|
||||
dbg!("Poll command!");
|
||||
|
||||
let res = fut.poll(cx);
|
||||
res
|
||||
});
|
||||
let future = future.await;
|
||||
dbg!(start.elapsed());
|
||||
|
||||
future.log_err().map(|output| output.stdout)
|
||||
smol::process::Command::new(command)
|
||||
.args(args)
|
||||
.output()
|
||||
.await
|
||||
.log_err()
|
||||
.map(|output| output.stdout)
|
||||
})?
|
||||
.init(include_bytes!("../../../../plugins/bin/json_language.wasm"))
|
||||
.await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue