Skip to content

Commit 9963379

Browse files
committed
Don't ignore other kinds of error coming out of execute_process
For example, the old code ignores serde errors Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
1 parent 3ced053 commit 9963379

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

src/main.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,25 @@ fn calculate_lsp_params(params: Value) -> Result<LspParams> {
5454
});
5555

5656
if let Some(server_path) = server_path {
57-
let program = match std::env::var("VOLT_OS").as_deref() {
57+
let program = match VoltEnvironment::operating_system().as_deref() {
5858
Ok("windows") => "where",
5959
_ => "which",
6060
};
61-
let exists = PLUGIN_RPC
61+
return match PLUGIN_RPC
6262
.execute_process(program.to_string(), vec![server_path.to_string()])
6363
.map(|r| r.success)
64-
.unwrap_or(false);
65-
if !exists {
66-
return Err(anyhow!(
64+
{
65+
Ok(true) => Ok((
66+
Url::parse(&format!("urn:{server_path}"))?,
67+
Vec::new(),
68+
document_filters,
69+
params.initialization_options,
70+
)),
71+
Ok(false) => Err(anyhow!(
6772
"Cannot find the LSP binary at the server path provided. Please check."
68-
));
69-
}
70-
return Ok((
71-
Url::parse(&format!("urn:{server_path}"))?,
72-
Vec::new(),
73-
document_filters,
74-
params.initialization_options,
75-
));
73+
)),
74+
Err(err) => Err(anyhow!("Unable to execute command because {}", err)),
75+
};
7676
}
7777

7878
let arch = match VoltEnvironment::architecture().as_deref() {
@@ -124,11 +124,9 @@ impl LapcePlugin for State {
124124
fn handle_request(&mut self, id: u64, method: String, params: Value) {
125125
#[allow(clippy::single_match)]
126126
match method.as_str() {
127-
Initialize::METHOD => match calculate_lsp_params(params) {
128-
Ok((server_uri, args, filters, params)) => {
129-
PLUGIN_RPC
130-
.start_lsp(server_uri, args, filters, params)
131-
.unwrap();
127+
Initialize::METHOD => match calculate_lsp_params(params.clone()) {
128+
Ok((uri, args, filters, params)) => {
129+
PLUGIN_RPC.start_lsp(uri, args, filters, params).unwrap();
132130
PLUGIN_RPC
133131
.host_success(id, InitializeResult::default())
134132
.unwrap()

0 commit comments

Comments
 (0)