From ee4b8e589172d9bfc4d175315b76c4c9a2a3aaf9 Mon Sep 17 00:00:00 2001 From: Leo Dev Date: Wed, 5 Jun 2024 19:50:23 +0200 Subject: [PATCH] just a small change --- src/lsp.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lsp.rs b/src/lsp.rs index b91b471..ae6eee4 100644 --- a/src/lsp.rs +++ b/src/lsp.rs @@ -4,7 +4,7 @@ use regex::Regex; use std::io::{stdin, stdout, Read}; pub fn run_lsp_server() { - let clpattern = Lazy::new(|| Regex::new(r"Content-Length: (\d+)\r\n").unwrap()); + let clpattern = Lazy::new(|| Regex::new(r"Content-Length: (\d+)\n").unwrap()); let mut sin = stdin(); let mut sout = stdout(); @@ -14,11 +14,11 @@ pub fn run_lsp_server() { let mut input = String::new(); let _ = sin.read_line(&mut input); if let Some(caps) = clpattern.captures(&input) { - let x = 30; - let mut buf = vec![0u8; x]; + let conent_len = *(&caps[1].parse::().unwrap()); + let mut buf = vec![0u8; conent_len]; sin.read_exact(&mut buf); + let json_string = String::from_utf8(buf).expect("Our bytes should be valid utf8"); - println!("{}", &caps[1]) } } } \ No newline at end of file