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:
parent
eecbf203dc
commit
bb75d87285
2 changed files with 8 additions and 34 deletions
|
@ -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,20 +932,12 @@ 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 });
|
||||
}
|
||||
new_value = serde_json::json!({ key.to_string(): new_value });
|
||||
}
|
||||
|
||||
if let Some(first_key_start) = first_key_start {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue