Skip to content

Commit 9acef3a

Browse files
committed
Ignore null values in workspace/configuration response
1 parent 8c54407 commit 9acef3a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

crates/emmylua_ls/src/handlers/initialized/client_config/default_config.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,26 @@ pub async fn get_client_config_default(
5757
info!("no client config found");
5858
}
5959

60+
for config in &mut configs {
61+
// VSCode always sends default values for all options, even those that weren't
62+
// explicitly configured by user. This results in `null`s being sent for
63+
// every option. Naturally, serde chokes on these nulls when applying partial
64+
// configuration.
65+
//
66+
// Because of this, we have to ignore them here.
67+
skip_nulls(config);
68+
}
69+
6070
config.partial_emmyrcs = Some(configs);
6171

6272
Some(())
6373
}
74+
75+
fn skip_nulls(v: &mut Value) {
76+
if let Value::Object(obj) = v {
77+
obj.retain(|_, v| !v.is_null());
78+
for (_, v) in obj {
79+
skip_nulls(v);
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)