Skip to content

Commit 5742e63

Browse files
fully remove async_std::task
1 parent 29fa629 commit 5742e63

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

crates/pg_lsp/src/server.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ mod debouncer;
22
mod dispatch;
33
pub mod options;
44

5-
use async_std::task::{self};
65
use lsp_server::{Connection, ErrorCode, Message, RequestId};
76
use lsp_types::{
87
notification::{
@@ -240,35 +239,33 @@ impl Server {
240239
});
241240
}
242241

243-
fn start_listening(&self) {
242+
async fn start_listening(&self) {
244243
if self.db_conn.is_none() {
245244
return;
246245
}
247246

248247
let pool = self.db_conn.as_ref().unwrap().pool.clone();
249248
let tx = self.internal_tx.clone();
250249

251-
task::spawn(async move {
252-
let mut listener = PgListener::connect_with(&pool).await.unwrap();
253-
listener
254-
.listen_all(["postgres_lsp", "pgrst"])
255-
.await
256-
.unwrap();
250+
let mut listener = PgListener::connect_with(&pool).await.unwrap();
251+
listener
252+
.listen_all(["postgres_lsp", "pgrst"])
253+
.await
254+
.unwrap();
257255

258-
loop {
259-
match listener.recv().await {
260-
Ok(notification) => {
261-
if notification.payload().to_string() == "reload schema" {
262-
tx.send(InternalMessage::RefreshSchemaCache).unwrap();
263-
}
264-
}
265-
Err(e) => {
266-
eprintln!("Listener error: {}", e);
267-
break;
256+
loop {
257+
match listener.recv().await {
258+
Ok(notification) => {
259+
if notification.payload().to_string() == "reload schema" {
260+
tx.send(InternalMessage::RefreshSchemaCache).unwrap();
268261
}
269262
}
263+
Err(e) => {
264+
eprintln!("Listener error: {}", e);
265+
break;
266+
}
270267
}
271-
});
268+
}
272269
}
273270

274271
async fn update_db_connection(&mut self, connection_string: Option<String>) {
@@ -298,9 +295,8 @@ impl Server {
298295
})
299296
.unwrap();
300297

301-
self.refresh_schema_cache();
302-
303-
self.start_listening();
298+
self.refresh_schema_cache().await;
299+
self.start_listening().await;
304300
}
305301

306302
fn update_options(&mut self, options: Options) {

crates/pg_schema_cache/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
#![feature(future_join)]
55

66
mod functions;
7-
mod versions;
87
mod schema_cache;
98
mod schemas;
109
mod tables;
1110
mod types;
11+
mod versions;
1212

1313
use sqlx::postgres::PgPool;
1414

xtask/src/install.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ fn install_client(sh: &Shell, client_opt: ClientOpt) -> anyhow::Result<()> {
137137
}
138138

139139
fn install_server(sh: &Shell) -> anyhow::Result<()> {
140-
let cmd = cmd!(
141-
sh,
142-
"cargo install --path crates/pg_lsp --locked --force"
143-
);
140+
let cmd = cmd!(sh, "cargo install --path crates/pg_lsp --locked --force");
144141
cmd.run()?;
145142
Ok(())
146143
}

0 commit comments

Comments
 (0)