First pass on fixes
This commit is contained in:
parent
5826d89b97
commit
2f3be75fc7
269 changed files with 1593 additions and 2574 deletions
|
@ -543,8 +543,8 @@ impl KeymapFile {
|
|||
//
|
||||
// When a struct with no deserializable fields is added by deriving `Action`, an empty
|
||||
// object schema is produced. The action should be invoked without data in this case.
|
||||
if let Some(schema) = action_schema {
|
||||
if schema != empty_object {
|
||||
if let Some(schema) = action_schema
|
||||
&& schema != empty_object {
|
||||
let mut matches_action_name = json_schema!({
|
||||
"const": name
|
||||
});
|
||||
|
@ -564,7 +564,6 @@ impl KeymapFile {
|
|||
});
|
||||
keymap_action_alternatives.push(action_with_input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Placing null first causes json-language-server to default assuming actions should be
|
||||
|
@ -593,11 +592,10 @@ impl KeymapFile {
|
|||
match fs.load(paths::keymap_file()).await {
|
||||
result @ Ok(_) => result,
|
||||
Err(err) => {
|
||||
if let Some(e) = err.downcast_ref::<std::io::Error>() {
|
||||
if e.kind() == std::io::ErrorKind::NotFound {
|
||||
if let Some(e) = err.downcast_ref::<std::io::Error>()
|
||||
&& e.kind() == std::io::ErrorKind::NotFound {
|
||||
return Ok(crate::initial_keymap_content().to_string());
|
||||
}
|
||||
}
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,11 +67,10 @@ pub fn watch_config_file(
|
|||
break;
|
||||
}
|
||||
|
||||
if let Ok(contents) = fs.load(&path).await {
|
||||
if tx.unbounded_send(contents).is_err() {
|
||||
if let Ok(contents) = fs.load(&path).await
|
||||
&& tx.unbounded_send(contents).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
@ -88,13 +87,11 @@ pub fn watch_config_dir(
|
|||
executor
|
||||
.spawn(async move {
|
||||
for file_path in &config_paths {
|
||||
if fs.metadata(file_path).await.is_ok_and(|v| v.is_some()) {
|
||||
if let Ok(contents) = fs.load(file_path).await {
|
||||
if tx.unbounded_send(contents).is_err() {
|
||||
if fs.metadata(file_path).await.is_ok_and(|v| v.is_some())
|
||||
&& let Ok(contents) = fs.load(file_path).await
|
||||
&& tx.unbounded_send(contents).is_err() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let (events, _) = fs.watch(&dir_path, Duration::from_millis(100)).await;
|
||||
|
@ -110,11 +107,10 @@ pub fn watch_config_dir(
|
|||
}
|
||||
}
|
||||
Some(PathEventKind::Created) | Some(PathEventKind::Changed) => {
|
||||
if let Ok(contents) = fs.load(&event.path).await {
|
||||
if tx.unbounded_send(contents).is_err() {
|
||||
if let Ok(contents) = fs.load(&event.path).await
|
||||
&& tx.unbounded_send(contents).is_err() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -369,14 +369,13 @@ pub fn replace_top_level_array_value_in_json_text(
|
|||
if cursor.node().kind() == "," {
|
||||
remove_range.end = cursor.node().range().end_byte;
|
||||
}
|
||||
if let Some(next_newline) = &text[remove_range.end + 1..].find('\n') {
|
||||
if text[remove_range.end + 1..remove_range.end + next_newline]
|
||||
if let Some(next_newline) = &text[remove_range.end + 1..].find('\n')
|
||||
&& text[remove_range.end + 1..remove_range.end + next_newline]
|
||||
.chars()
|
||||
.all(|c| c.is_ascii_whitespace())
|
||||
{
|
||||
remove_range.end = remove_range.end + next_newline;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while cursor.goto_previous_sibling()
|
||||
&& (cursor.node().is_extra() || cursor.node().is_missing())
|
||||
|
@ -508,11 +507,10 @@ pub fn append_top_level_array_value_in_json_text(
|
|||
replace_value.insert(0, ',');
|
||||
}
|
||||
} else {
|
||||
if let Some(prev_newline) = text[..replace_range.start].rfind('\n') {
|
||||
if text[prev_newline..replace_range.start].trim().is_empty() {
|
||||
if let Some(prev_newline) = text[..replace_range.start].rfind('\n')
|
||||
&& text[prev_newline..replace_range.start].trim().is_empty() {
|
||||
replace_range.start = prev_newline;
|
||||
}
|
||||
}
|
||||
let indent = format!("\n{space:width$}", width = tab_size);
|
||||
replace_value = replace_value.replace('\n', &indent);
|
||||
replace_value.insert_str(0, &indent);
|
||||
|
|
|
@ -346,15 +346,13 @@ impl SettingsStore {
|
|||
}
|
||||
|
||||
let mut profile_value = None;
|
||||
if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() {
|
||||
if let Some(profiles) = self.raw_user_settings.get("profiles") {
|
||||
if let Some(profile_settings) = profiles.get(&active_profile.0) {
|
||||
if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>()
|
||||
&& let Some(profiles) = self.raw_user_settings.get("profiles")
|
||||
&& let Some(profile_settings) = profiles.get(&active_profile.0) {
|
||||
profile_value = setting_value
|
||||
.deserialize_setting(profile_settings)
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let server_value = self
|
||||
.raw_server_settings
|
||||
|
@ -482,11 +480,10 @@ impl SettingsStore {
|
|||
match fs.load(paths::settings_file()).await {
|
||||
result @ Ok(_) => result,
|
||||
Err(err) => {
|
||||
if let Some(e) = err.downcast_ref::<std::io::Error>() {
|
||||
if e.kind() == std::io::ErrorKind::NotFound {
|
||||
if let Some(e) = err.downcast_ref::<std::io::Error>()
|
||||
&& e.kind() == std::io::ErrorKind::NotFound {
|
||||
return Ok(crate::initial_user_settings_content().to_string());
|
||||
}
|
||||
}
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
|
@ -496,11 +493,10 @@ impl SettingsStore {
|
|||
match fs.load(paths::global_settings_file()).await {
|
||||
result @ Ok(_) => result,
|
||||
Err(err) => {
|
||||
if let Some(e) = err.downcast_ref::<std::io::Error>() {
|
||||
if e.kind() == std::io::ErrorKind::NotFound {
|
||||
if let Some(e) = err.downcast_ref::<std::io::Error>()
|
||||
&& e.kind() == std::io::ErrorKind::NotFound {
|
||||
return Ok("{}".to_string());
|
||||
}
|
||||
}
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
|
@ -955,15 +951,14 @@ impl SettingsStore {
|
|||
let mut setting_schema = setting_value.json_schema(&mut generator);
|
||||
|
||||
if let Some(key) = setting_value.key() {
|
||||
if let Some(properties) = combined_schema.get_mut("properties") {
|
||||
if let Some(properties_obj) = properties.as_object_mut() {
|
||||
if let Some(properties) = combined_schema.get_mut("properties")
|
||||
&& let Some(properties_obj) = properties.as_object_mut() {
|
||||
if let Some(target) = properties_obj.get_mut(key) {
|
||||
merge_schema(target, setting_schema.to_value());
|
||||
} else {
|
||||
properties_obj.insert(key.to_string(), setting_schema.to_value());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setting_schema.remove("description");
|
||||
setting_schema.remove("additionalProperties");
|
||||
|
@ -1038,8 +1033,7 @@ impl SettingsStore {
|
|||
| "additionalProperties" => {
|
||||
if let Some(old_value) =
|
||||
target_obj.insert(source_key.clone(), source_value.clone())
|
||||
{
|
||||
if old_value != source_value {
|
||||
&& old_value != source_value {
|
||||
log::error!(
|
||||
"bug: while merging JSON schemas, \
|
||||
mismatch `\"{}\": {}` (before was `{}`)",
|
||||
|
@ -1048,7 +1042,6 @@ impl SettingsStore {
|
|||
source_value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
log::error!(
|
||||
|
@ -1168,35 +1161,30 @@ impl SettingsStore {
|
|||
if let Some(release_settings) = &self
|
||||
.raw_user_settings
|
||||
.get(release_channel::RELEASE_CHANNEL.dev_name())
|
||||
{
|
||||
if let Some(release_settings) = setting_value
|
||||
&& let Some(release_settings) = setting_value
|
||||
.deserialize_setting(release_settings)
|
||||
.log_err()
|
||||
{
|
||||
release_channel_settings = Some(release_settings);
|
||||
}
|
||||
}
|
||||
|
||||
let mut os_settings = None;
|
||||
if let Some(settings) = &self.raw_user_settings.get(env::consts::OS) {
|
||||
if let Some(settings) = setting_value.deserialize_setting(settings).log_err() {
|
||||
if let Some(settings) = &self.raw_user_settings.get(env::consts::OS)
|
||||
&& let Some(settings) = setting_value.deserialize_setting(settings).log_err() {
|
||||
os_settings = Some(settings);
|
||||
}
|
||||
}
|
||||
|
||||
let mut profile_settings = None;
|
||||
if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() {
|
||||
if let Some(profiles) = self.raw_user_settings.get("profiles") {
|
||||
if let Some(profile_json) = profiles.get(&active_profile.0) {
|
||||
if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>()
|
||||
&& let Some(profiles) = self.raw_user_settings.get("profiles")
|
||||
&& let Some(profile_json) = profiles.get(&active_profile.0) {
|
||||
profile_settings =
|
||||
setting_value.deserialize_setting(profile_json).log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the global settings file changed, reload the global value for the field.
|
||||
if changed_local_path.is_none() {
|
||||
if let Some(value) = setting_value
|
||||
if changed_local_path.is_none()
|
||||
&& let Some(value) = setting_value
|
||||
.load_setting(
|
||||
SettingsSources {
|
||||
default: &default_settings,
|
||||
|
@ -1215,7 +1203,6 @@ impl SettingsStore {
|
|||
{
|
||||
setting_value.set_global_value(value);
|
||||
}
|
||||
}
|
||||
|
||||
// Reload the local values for the setting.
|
||||
paths_stack.clear();
|
||||
|
@ -1223,13 +1210,12 @@ impl SettingsStore {
|
|||
for ((root_id, directory_path), local_settings) in &self.raw_local_settings {
|
||||
// Build a stack of all of the local values for that setting.
|
||||
while let Some(prev_entry) = paths_stack.last() {
|
||||
if let Some((prev_root_id, prev_path)) = prev_entry {
|
||||
if root_id != prev_root_id || !directory_path.starts_with(prev_path) {
|
||||
if let Some((prev_root_id, prev_path)) = prev_entry
|
||||
&& (root_id != prev_root_id || !directory_path.starts_with(prev_path)) {
|
||||
paths_stack.pop();
|
||||
project_settings_stack.pop();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue