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"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
|
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]]
|
[[package]]
|
||||||
name = "futures"
|
name = "futures"
|
||||||
version = "0.3.21"
|
version = "0.3.21"
|
||||||
|
@ -7018,7 +7009,6 @@ dependencies = [
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"file_finder",
|
"file_finder",
|
||||||
"fsevent",
|
"fsevent",
|
||||||
"future-wrap",
|
|
||||||
"futures",
|
"futures",
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
"go_to_line",
|
"go_to_line",
|
||||||
|
|
|
@ -1732,8 +1732,9 @@ impl Project {
|
||||||
.await?;
|
.await?;
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.assign_language_to_buffer(&buffer, 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(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1791,6 +1792,7 @@ impl Project {
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
self.assign_language_to_buffer(buffer, cx);
|
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;
|
self.register_buffer_with_language_server(buffer, cx).await;
|
||||||
cx.observe_release(buffer, |this, buffer, cx| {
|
cx.observe_release(buffer, |this, buffer, cx| {
|
||||||
if let Some(file) = File::from_dyn(buffer.file()) {
|
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"
|
tree-sitter-typescript = "0.20.1"
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
|
|
||||||
# TODO(isaac): remove this
|
|
||||||
future-wrap = "0.1.1"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
text = { path = "../text", features = ["test-support"] }
|
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 std::{any::Any, path::PathBuf, sync::Arc};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
use future_wrap::*;
|
|
||||||
|
|
||||||
pub async fn new_json(executor: Arc<Background>) -> Result<PluginLspAdapter> {
|
pub async fn new_json(executor: Arc<Background>) -> Result<PluginLspAdapter> {
|
||||||
let plugin = PluginBuilder::new_with_default_ctx()?
|
let plugin = PluginBuilder::new_with_default_ctx()?
|
||||||
.host_function_async("command", |command: String| async move {
|
.host_function_async("command", |command: String| async move {
|
||||||
dbg!(&command);
|
dbg!(&command);
|
||||||
|
|
||||||
// TODO: actual thing
|
|
||||||
let mut args = command.split(' ');
|
let mut args = command.split(' ');
|
||||||
let command = args.next().unwrap();
|
let command = args.next().unwrap();
|
||||||
|
smol::process::Command::new(command)
|
||||||
dbg!("Running external command");
|
.args(args)
|
||||||
|
.output()
|
||||||
let start = std::time::Instant::now();
|
.await
|
||||||
let future = smol::process::Command::new(command).args(args).output();
|
.log_err()
|
||||||
let future = future.wrap(|fut, cx| {
|
.map(|output| output.stdout)
|
||||||
dbg!("Poll command!");
|
|
||||||
|
|
||||||
let res = fut.poll(cx);
|
|
||||||
res
|
|
||||||
});
|
|
||||||
let future = future.await;
|
|
||||||
dbg!(start.elapsed());
|
|
||||||
|
|
||||||
future.log_err().map(|output| output.stdout)
|
|
||||||
})?
|
})?
|
||||||
.init(include_bytes!("../../../../plugins/bin/json_language.wasm"))
|
.init(include_bytes!("../../../../plugins/bin/json_language.wasm"))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue