Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fzf-lua] latest commits in dressing might not be necessary anymore #142

Closed
ibhagwan opened this issue Jan 27, 2024 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@ibhagwan
Copy link
Contributor

Hi @stevearc,

Context: ibhagwan/fzf-lua#1014

It seems I really misconfigured dressing. Sorry for the trouble

After the above report I decided to test fzf-lua with dressing, to my surprise I saw the latest 2 commits (namely 9f9b773) and this comment:

-- Because fzf-lua doesn't call the on_choice function if exited (e.g. with <C-c>), we need to
-- add an autocmd ourselves to make sure that happens.

This made no sense as I had written the code in the past in such a way that should call on_choice with nil when no item is selected.

Turns out, some time ago I added "dummy" actions (keybinds) for ctrl-c/esc (for better resume support) which in turn affected the code route I had setup before to call on_choice(nil, nil) when no item was selected. While I appreiate the innovative solution your commits 😄 I think it's better to also solve the original bug (on_choice must be called according to the docs):

Fixed in ibhagwan/fzf-lua@5474df3, the new code flow (I can probablly eliminate the if not selected route, left for posterity):

    if not selected then
      -- with `actions.dummy_abort` this doesn't get called anymore
      -- as the action is configured as a valid fzf "accept" (thus
      -- `selected` isn't empty), see below comment for mor info
      on_choice(nil, nil)
    else
      o._on_choice_called = nil
      actions.act(o.actions, selected, o)
      if not o._on_choice_called then
        -- see  comment above, `on_choice` wasn't called, either
        -- "dummy_abort" (ctrl-c/esc) or (unlikely) the user setup
        -- additional binds that aren't for "accept". Not calling
        -- with nil (no action) can cause issues, for example with
        -- dressing.nvim (#1014)
        on_choice(nil, nil)
      end
    end
``
@ibhagwan ibhagwan added the bug Something isn't working label Jan 27, 2024
@stevearc
Copy link
Owner

That's great news! I was going to report this, but I noticed the behavior mid-week and just needed to get a fix in ASAP. Glad it was fixed upstream!

@ibhagwan
Copy link
Contributor Author

That's great news! I was going to report this, but I noticed the behavior mid-week and just needed to get a fix in ASAP. Glad it was fixed upstream!

Ty @stevearc!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants