Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

picker: Fix layout persistency with preview setting change (#59827)

ozacod64b8491fc63b
diff --git a/crates/picker/src/persistence.rs b/crates/picker/src/persistence.rs
index ab61859abd8..59de6cf8bf2 100644
--- a/crates/picker/src/persistence.rs
+++ b/crates/picker/src/persistence.rs
@@ -36,6 +36,26 @@ pub(crate) fn store_shape_for_this_layout(
});
}
+/// Persist the last-used preview layout without touching the stored shape.
+///
+/// Changing the preview position (e.g. right/below/hidden) without resizing
+/// must still be remembered, so this is called whenever the layout changes.
+pub(crate) fn store_last_layout(
+ picker_delegate: &'static str,
+ preview_layout: Option<preview::Layout>,
+ cx: &App,
+) {
+ let kvp = KeyValueStore::global(cx);
+ db::write_and_log(cx, async move || {
+ kvp.scoped(PICKERS_NAMESPACE)
+ .write(
+ last_layout_key(picker_delegate),
+ layout_as_str(preview_layout).to_string(),
+ )
+ .await
+ });
+}
+
pub(crate) fn try_load_shape(
picker_delegate: &'static str,
preview_layout: impl Into<Option<preview::Layout>>,
diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs
index c655cb0a463..352f60168ea 100644
--- a/crates/picker/src/picker.rs
+++ b/crates/picker/src/picker.rs
@@ -1260,6 +1260,8 @@ impl<D: PickerDelegate> Picker<D> {
_window: &mut Window,
cx: &mut Context<Self>,
) {
+ persistence::store_last_layout(D::name(), self.preview.as_ref().map(|_| layout), cx);
+
let Some(preview) = &mut self.preview else {
return;
};