Skip to content

mini.pick: vim.deepcopy fails on items containing userdata (e.g., uv_timer_t) #2279

@DanRioDev

Description

@DanRioDev

Hi, thanks for mini.nvim, I use it every day.

I hit an issue with mini.pick when it's used as the vim.ui.select backend. When items passed to vim.ui.select contain userdata (like uv.uv_timer_t handles), mini.pick crashes because vim.deepcopy() can't handle userdata.

Error: Cannot deepcopy object of type userdata

It happens in H.validate_picker_opts() at line 2077 where it does:

opts = vim.deepcopy(H.get_config(opts))

This deepcopies everything including source.items. If any item has userdata in it, it breaks.

I ran into this with sidekick.nvim - it passes state objects to vim.ui.select, and some of those have terminal objects with uv timer handles inside.

A couple ideas for fixing it:

  • Use shallow copy or selective copy instead of full deepcopy
  • Wrap the deepcopy in pcall and fall back to the original if it fails
  • Or just note in the docs that items shouldn't have userdata

Let me know if you want me to test anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions