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:
Ben Kunkle
2025-10-27 10:13:26 -04:00
committed by GitHub
co-authored by Danilo
parent 5d359ea2f2
commit 2f7045f724
14 changed files with 373 additions and 144 deletions
+4 -3
View File
@@ -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(&current_text);
let json_indent_size = infer_json_indent_size(&current_text);
for migration in migrations.iter() {
let migrated_text = match migration {
MigrationType::TreeSitter(patterns, query) => migrate(&current_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(&current_text)?;
parse_json_with_comments(&current_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,