Remove language_overrides setting alias (#13164)

This PR removes the `language_overrides` alias for the `languages`
setting.

I've seen a number of people run into issues where they have both
`languages` and `language_overrides` in their settings and get confused
when their settings don't seem to apply as expected.

This is a breaking change, but I think it is a necessary one to prevent
more users from running into issues.

Release Notes:

- Breaking Change: Removed the `language_overrides` alias for the
`languages` setting. If you have settings under `language_overrides`
they should get moved to `languages`.
This commit is contained in:
Marshall Bowers 2024-06-17 14:50:45 -04:00 committed by GitHub
parent eecbf203dc
commit bb75d87285
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 34 deletions

View File

@ -200,7 +200,7 @@ pub struct AllLanguageSettingsContent {
#[serde(flatten)]
pub defaults: LanguageSettingsContent,
/// The settings for individual languages.
#[serde(default, alias = "language_overrides")]
#[serde(default)]
pub languages: HashMap<Arc<str>, LanguageSettingsContent>,
/// Settings for associating file extensions and filenames
/// with languages.
@ -754,17 +754,10 @@ impl settings::Settings for AllLanguageSettings {
.as_mut()
.unwrap()
.properties
.extend([
(
.extend([(
"languages".to_owned(),
Schema::new_ref("#/definitions/Languages".into()),
),
// For backward compatibility
(
"language_overrides".to_owned(),
Schema::new_ref("#/definitions/Languages".into()),
),
]);
)]);
root_schema
}

View File

@ -866,9 +866,6 @@ fn replace_value_in_json_text(
tab_size: usize,
new_value: &serde_json::Value,
) -> (Range<usize>, String) {
const LANGUAGE_OVERRIDES: &str = "language_overrides";
const LANGUAGES: &str = "languages";
lazy_static! {
static ref PAIR_QUERY: tree_sitter::Query = tree_sitter::Query::new(
&tree_sitter_json::language(),
@ -883,8 +880,6 @@ fn replace_value_in_json_text(
let mut cursor = tree_sitter::QueryCursor::new();
let has_language_overrides = text.contains(LANGUAGE_OVERRIDES);
let mut depth = 0;
let mut last_value_range = 0..0;
let mut first_key_start = None;
@ -914,13 +909,7 @@ fn replace_value_in_json_text(
let found_key = text
.get(key_range.clone())
.map(|key_text| {
if key_path[depth] == LANGUAGES && has_language_overrides {
key_text == format!("\"{}\"", LANGUAGE_OVERRIDES)
} else {
key_text == format!("\"{}\"", key_path[depth])
}
})
.map(|key_text| key_text == format!("\"{}\"", key_path[depth]))
.unwrap_or(false);
if found_key {
@ -943,21 +932,13 @@ fn replace_value_in_json_text(
(existing_value_range, new_val)
} else {
// We have key paths, construct the sub objects
let new_key = if has_language_overrides && key_path[depth] == LANGUAGES {
LANGUAGE_OVERRIDES
} else {
key_path[depth]
};
let new_key = key_path[depth];
// We don't have the key, construct the nested objects
let mut new_value = serde_json::to_value(new_value).unwrap();
for key in key_path[(depth + 1)..].iter().rev() {
if has_language_overrides && key == &LANGUAGES {
new_value = serde_json::json!({ LANGUAGE_OVERRIDES.to_string(): new_value });
} else {
new_value = serde_json::json!({ key.to_string(): new_value });
}
}
if let Some(first_key_start) = first_key_start {
let mut row = 0;