Skip to content
New issue

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

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

Already on GitHub? # to your account

Multiple file behavior is surprising and limited (vs fzf) #496

Closed
davidmathers opened this issue Aug 10, 2020 · 6 comments · Fixed by #497
Closed

Multiple file behavior is surprising and limited (vs fzf) #496

davidmathers opened this issue Aug 10, 2020 · 6 comments · Fixed by #497

Comments

@davidmathers
Copy link

Current behavior:

Use Tab to select multiple entries and open them using the quickfix window.
Use Ctrl-t or Ctrl-x, Ctrl-v to open the selected entry in a new tab or a new split.

Desired behavior:

Use Tab to select multiple entries.
Use Ctrl-t or Ctrl-x, Ctrl-v to open the selected entries in new tabs or new splits.
Use Ctrl-q to open the selected entries using the quickfix window.

Using FZF I can select 2 files and press Ctrl-v to open them in splits. I was expecting the same behavior with Clap and was surprised when that didn't work.

I feel that the "open actions" should be applicable whether a single file is selected or multiple files are selected.

In FZF I have also added Ctrl-a for "argadd" to use the arglist when I want to open several files at once. I am prevented from doing the same with Clap.

@issue-label-bot issue-label-bot bot added the bug Something isn't working label Aug 10, 2020
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.57. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@liuchengxu liuchengxu removed the bug Something isn't working label Aug 10, 2020
@liuchengxu
Copy link
Owner

liuchengxu commented Aug 10, 2020

Use Tab to select multiple entries and open them using the quickfix window.

This might be a bit confusing. Actually you can use Tab to select multiple entries and have to press Enter to open them using the quickfix window for thefiles like provider, the Enter part is missing and not all the providers are appliable. Furthermore, I don't think Ctrl-q is more convenient than Enter.

Use Ctrl-t or Ctrl-x, Ctrl-v to open the selected entries in new tabs or new splits.

Good point, this can be improved.

liuchengxu added a commit that referenced this issue Aug 10, 2020
@liuchengxu
Copy link
Owner

Use Ctrl-t or Ctrl-x, Ctrl-v to open the selected entries in new tabs or new splits.

@davidmathers This has been supported in https://github.com/liuchengxu/vim-clap/tree/support-open-action-for-multiple-selections. Let me know if you have more ideas.

@davidmathers
Copy link
Author

Perfect. And I do have more ideas :)

First is something FZF does that some may disagree with but I think is good: if the current buffer is unused then it ignores the open action for the first file and executes 'edit' instead. That way the unused buffer vanishes, which I think is usually wanted.

Second is support for using 'argadd' as an open action. Maybe I am the only person in the world who wants to use the arglist but it requires special handling.

Here is an example. It seems to work except for the execute 'edit' line:

  let lines = s:get_opaque_lines()

  " use current buffer if it is unused
  if empty(expand('%')) && !&modified
    execute 'edit' lines[0]
    unlet lines[0]
  endif

  " If the open action uses the argument list then add the current file to the list
  if g:clap.open_action[0:2] ==# 'arg' && argv(argidx()) !=# @%
    execute 'argadd'
  endif

  for line in lines
    call g:clap.provider.sink(line)
  endfor

@liuchengxu
Copy link
Owner

Hmm, I don't quite get the point of your last ideas. You might want to customize the sink function of the provider. I'm not a fan of introducing too many stuffs in the framework which may not be used widely.

@davidmathers
Copy link
Author

To clarify. If I am looking at an empty buffer and select 2 files and press ctrl-v:

Using FZF I will be looking at 2 windows. One for each file.
Using Clap I will be looking at 3 windows. One for each file plus the original empty buffer.

The Clap behavior makes perfect sense. But personally I prefer the FZF behavior as a convenience.

I will learn about customizing the sink function and see if that solves my arglist problem.

Thanks for making Clap!

liuchengxu added a commit that referenced this issue Aug 12, 2020
* Support open action for multiple selections

Close #496

* Update CHANGELOG
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants