vim-qf icon indicating copy to clipboard operation
vim-qf copied to clipboard

[feature] Allow Keep and Reject operate on ranges (Visual Selection)

Open balta2ar opened this issue 6 years ago • 7 comments

Hi. My use case is that I often filter out certain entries from quickfix window to reduce the scope. Even though Keep and Reject currently do the job, I believe it could be a bit more convenient to support exclusion (and inclusion) of results by visually selecting them (line selection) and calling Reject (or Keep) on the selected range. Could you please implement that? Thank you!

balta2ar avatar Apr 28 '18 14:04 balta2ar

This is a very reasonable request and I already have all the necessary bits and pieces. I'll look into it

romainl avatar Apr 28 '18 15:04 romainl

Please checkout the latest commit.

romainl avatar Apr 29 '18 15:04 romainl

Thanks! I've tried your changes and I'm afraid there are still some rough edges...

  1. When visual selection spans multiple filenames OR when only one line across many with the same filename is selected, and Reject is called.

vim-qf-reject-one-line-of-many-or-spans-different-files

  1. Basically the same cases but with Keep.

vim-qf-keep-spans-many

balta2ar avatar Apr 29 '18 20:04 balta2ar

Yeah, my initial assumption is that the user visually selects a word or parts of a word. Does it really make sense to visually select multiple lines?

Hmm… I see now that I may have misread your request. Something like :5,8Keep actually makes a lot of sense. Back to the drawing board!

romainl avatar Apr 29 '18 21:04 romainl

You mean that if you select a word, it's sent to Keep/Reject as an argument? Hmm, to be honest, never thought of that, but I think it's also reasonable and convenient.

As for multiple lines, sure, it makes sense. Before you explained your vision, only multiple line selection made sense to me when I created this request. It's just that I prefer to manually select lines that I want to keep/get rid of. Thus, my selection should not be treated as a pattern, just as a range. I guess vim plugin can differentiate between line and word selection? If it's a word selection, the old logic applies, if it's a line selection, the lines in the range should be removed/kept. That was my intuition and anticipation when I tried to use Keep/Reject on a block of lines.

balta2ar avatar Apr 29 '18 21:04 balta2ar

OK, now that it's clear I can move forward.

romainl avatar Apr 29 '18 22:04 romainl

It has been a while and I apologise for the delay.

I just pushed range support for :Keep and :Reject.

You can now do :.Reject to remove the currently selected entry or :10,15Reject to remove entries 10-15. Same for :Keep.

Happy to get any feedback.

romainl avatar Mar 28 '21 10:03 romainl