settings_ui: Show migration banner (#41112)
Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ... --------- Co-authored-by: Danilo <danilo@zed.dev>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
//! You only need to write replacement logic for x-1 to x because you can be certain that, internally, every user will be at x-1, regardless of their on disk state.
|
||||
|
||||
use anyhow::{Context as _, Result};
|
||||
use settings_json::{infer_json_indent_size, parse_json_with_comments, update_value_in_json_text};
|
||||
use std::{cmp::Reverse, ops::Range, sync::LazyLock};
|
||||
use streaming_iterator::StreamingIterator;
|
||||
use tree_sitter::{Query, QueryMatch};
|
||||
@@ -74,7 +75,7 @@ fn run_migrations(text: &str, migrations: &[MigrationType]) -> Result<Option<Str
|
||||
|
||||
let mut current_text = text.to_string();
|
||||
let mut result: Option<String> = None;
|
||||
let json_indent_size = settings::infer_json_indent_size(¤t_text);
|
||||
let json_indent_size = infer_json_indent_size(¤t_text);
|
||||
for migration in migrations.iter() {
|
||||
let migrated_text = match migration {
|
||||
MigrationType::TreeSitter(patterns, query) => migrate(¤t_text, patterns, query)?,
|
||||
@@ -83,14 +84,14 @@ fn run_migrations(text: &str, migrations: &[MigrationType]) -> Result<Option<Str
|
||||
return Ok(None);
|
||||
}
|
||||
let old_content: serde_json_lenient::Value =
|
||||
settings::parse_json_with_comments(¤t_text)?;
|
||||
parse_json_with_comments(¤t_text)?;
|
||||
let old_value = serde_json::to_value(&old_content).unwrap();
|
||||
let mut new_value = old_value.clone();
|
||||
callback(&mut new_value)?;
|
||||
if new_value != old_value {
|
||||
let mut current = current_text.clone();
|
||||
let mut edits = vec![];
|
||||
settings::update_value_in_json_text(
|
||||
update_value_in_json_text(
|
||||
&mut current,
|
||||
&mut vec![],
|
||||
json_indent_size,
|
||||
|
||||
Reference in New Issue
Block a user