diff --git a/crates/picker/src/persistence.rs b/crates/picker/src/persistence.rs index ab61859abd..59de6cf8bf 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, + 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>, diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs index c655cb0a46..352f60168e 100644 --- a/crates/picker/src/picker.rs +++ b/crates/picker/src/picker.rs @@ -1260,6 +1260,8 @@ impl Picker { _window: &mut Window, cx: &mut Context, ) { + persistence::store_last_layout(D::name(), self.preview.as_ref().map(|_| layout), cx); + let Some(preview) = &mut self.preview else { return; };