Skip to content

Commit 567b253

Browse files
committed
feat(backend/lsp): Send lsp request to client
1 parent 76266f2 commit 567b253

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

backend/src/project/project_lsp.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ impl StreamHandler<Stdout> for ProjectLsp {
315315
}
316316
LspOutput::Request(req) => {
317317
local_log::request::trace!(target: self.project_id, "{req:?}");
318+
match serde_json::to_value(req) {
319+
Ok(data) => {
320+
_ = self.broadcast.send(InternalMessage::Lsp {
321+
client_id: None,
322+
data,
323+
});
324+
}
325+
Err(err) => {
326+
local_log::request::error!(target: self.project_id, "Cannot serialize {err:?}");
327+
}
328+
}
318329
}
319330
LspOutput::Notify(noti) => {
320331
local_log::notify::trace!(target: self.project_id, "{noti:?}");

backend/src/project/routes.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ pub async fn create_project(
8585

8686
project.permit_access(user_info.id.clone(), AccessLevel::Editor);
8787

88-
project.start_lsp().await;
89-
9088
Ok(HttpResponse::Created().json(json!({
9189
"id": project.id
9290
})))

backend/src/utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub use async_default::AsyncDefault;
99
pub use async_from::AsyncInto;
1010
pub use expect_var::expect_var;
1111
pub(crate) use logger::define_local_logger;
12-
pub use printers::{Truncate, Truncated};
12+
pub use printers::Truncate;
1313
pub use to_stream::ToStream;
1414

1515
use std::sync::{Arc, LazyLock};

backend/src/ws/messages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use uuid::Uuid;
99

1010
use crate::collab::{Document, DocumentInfo, UserOperation};
1111
use crate::project::AccessLevel;
12-
use crate::utils::{ArcStr, Truncate, Truncated};
12+
use crate::utils::{ArcStr, Truncate};
1313

1414
#[derive(Serialize, Deserialize)]
1515
#[serde(tag = "action", rename_all = "snake_case")]

backend/src/ws/websocket.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,16 @@ impl RgWebsocket {
4040
};
4141
let mut project = project.write().await;
4242

43+
let access = project.join_project(user_info.id.clone(), password)?;
44+
45+
if access.can_read() {
46+
project.start_lsp().await;
47+
}
48+
4349
(
4450
project.internal.subscribe(),
4551
project.broadcast.subscribe(),
46-
project.join_project(user_info.id.clone(), password)?,
52+
access,
4753
)
4854
};
4955

0 commit comments

Comments
 (0)