Merge pull request #34 from kbwo/feat/handle-shutdown-exit

feat: handle `shutdown` and `exit`
This commit is contained in:
Kodai Kabasawa 2024-09-23 17:57:23 +09:00 committed by GitHub
commit 245fd10346
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View file

@ -85,6 +85,13 @@ fn main_loop(server: &mut TestingLS) -> Result<(), LSError> {
let id = value["id"].as_i64().unwrap();
server.initialize(id, initialize_params)?;
}
"shutdown" => {
let id = value["id"].as_i64().unwrap();
server.shutdown(id)?;
}
"exit" => {
std::process::exit(0);
}
"workspace/diagnostic" => {
server.diagnose_workspace()?;
}

View file

@ -452,6 +452,15 @@ impl TestingLS {
}))?;
Ok(())
}
pub fn shutdown(&self, id: i64) -> Result<(), LSError> {
send_stdout(&json!({
"jsonrpc": "2.0",
"id": id,
"method": json!(null),
}))?;
Ok(())
}
}
#[cfg(test)]