## Description
The scratch module uses `vim.ui.select` which misses the nice things
about the picker.
This implementation adds scratch picker with ability to create, grep and
delete scratch buffers.
Couldn't figure out how to prettify the scratch buffer's name so any
help would be appreciated.
## Related Issue(s)
<!--
If this PR fixes any issues, please link to the issue here.
- Fixes #<issue_number>
-->
## Screenshots
<!-- Add screenshots of the changes if applicable. -->
---------
Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
## Description
I work a lot with detached `HEAD` in Git repos and noticed that the
scratch files for those were missing in `Snacks.scratch.select()`.
When working with a detached head, the `git branch --show-current`
returns an empty string, so ret will be `nil` in this case. This breaks
the scratch filename generation. The `table.concat` skips the `nil`
value, so the generated filename is missing one `|` separator. This will
later break in `M.list()`: `file_decode` and `match` will confuse
`branch` and `ft`, and the entry is not added to the items list.
A simple fix for this is to fallback to an empty string for the branch
name.
## Related Issue(s)
I didn't create an issue but fixed the problem right away. Hope this is
fine.
## Screenshots
I can provide one if requested.
## Description
Problem: opts.icon can be a table {icon, icon_hl} but the code inserts
opts.icon directly into filekey and later does table.concat(filekey,
"|"). That crashes when an element is a table.
Fix: use the first element of opts.icon when opts.icon is a table
(fallback to opts.icon or "").
## Related Issue(s)
N/A
## Screenshots
This happens when scratch.opts.icon is a table per documentation
<img width="1453" height="159" alt="image"
src="https://github.com/user-attachments/assets/c22cf58e-517d-400d-87d4-d05830df530d"
/>
## Description
When toggling scratch closed, it's possible for the active buffer to be
something other than the scratch buffer.
This results in the autowrite behaviour triggering a `write` for
whatever that active buffer was and leaving the scratch buffer as dirty.
## Related Issue(s)
- Fixes#449.