# picker: Fix layout persistency with preview setting change \(\#59827\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/64b8491fc63bcf6c894739e137c333c865e421ca)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 64b8491fc63bcf6c894739e137c333c865e421ca

Requested commit: 64b8491fc63bcf6c894739e137c333c865e421ca

Commit: 64b8491fc63bcf6c894739e137c333c865e421ca

Tree: 2da6ccacc021b00fbc9db70e524793493a75eb72

Author: ozacod

Committer: GitHub

## Message

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

## Summary

When you change a picker's preview position (toggle it, or set it
right/below/hidden), that choice should be remembered the next time the
picker opens. Previously it wasn't: the last-used layout was only
written to the database as a side effect of
`store_shape_for_this_layout`, which runs exclusively when a resize
completes (`render.rs`). So changing only the preview position without
also dragging to resize, was forgotten on the next open.

All layout changes funnel through a single chokepoint,
`set_preview_layout`, but it only updated the in-memory `preview.layout`
and reloaded the per-layout shape; it never persisted the layout key.

## Solution

`set_preview_layout` now persists the layout immediately via a new
`store_last_layout` helper, which writes just the
`LAST_PREVIEW_LAYOUT` key — deliberately without writing the current
shape, so a never-resized layout's default size isn't frozen into the
database as if the user had chosen it.

  Both persistence paths are now correct:
  - Resize completes — saves size and layout (unchanged).
- Position-only change (toggle / set right / set below / set hidden)
saves the layout right away.

This applies to every picker with a preview (file finder, text finder),
since the persistence is keyed generically by the picker delegate name.

## Testing

- Manual: open the file and text finder → switch the preview to Below
(or Right) without resizing → close and reopen → it returns in that
position; hide the preview → reopen → it stays hidden. Resizing still
persists size as before.

Release Notes:

- Fixed picker preview position not being remembered when changed
without resizing the picker

---------

Co-authored-by: ozacod <ozacod@users.noreply.github.com>
```

## Parents

- [a1d0015e70b22c6f8bd2da37c1e0861b2b55b82b](https://git.cafe/gitcafe/zed/commit/a1d0015e70b22c6f8bd2da37c1e0861b2b55b82b?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/64b8491fc63bcf6c894739e137c333c865e421ca?format=markdown)
