Add a better API for updating settings in the SettingsStore in tests
This commit is contained in:
parent
bc5b78198a
commit
9ae10a5dd9
3 changed files with 42 additions and 23 deletions
|
@ -172,12 +172,10 @@ pub fn update_settings_file<T: Setting>(
|
|||
})
|
||||
.await?;
|
||||
|
||||
let edits = cx.read(|cx| cx.global::<SettingsStore>().update::<T>(&old_text, update));
|
||||
|
||||
let mut new_text = old_text;
|
||||
for (range, replacement) in edits.into_iter().rev() {
|
||||
new_text.replace_range(range, &replacement);
|
||||
}
|
||||
let new_text = cx.read(|cx| {
|
||||
cx.global::<SettingsStore>()
|
||||
.new_text_for_update::<T>(old_text, update)
|
||||
});
|
||||
|
||||
cx.background()
|
||||
.spawn(async move { fs.atomic_write(paths::SETTINGS.clone(), new_text).await })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue