mileszs / ack.vim

Vim plugin for the Perl module / CLI script 'ack'
Other
3.08k stars 396 forks source link

Show message if no matches found #167

Open jonashaag opened 9 years ago

jonashaag commented 9 years ago

Current behaviour: If no matches are found, an empty result list is displayed. My suggestion: Show a message like "No matches found for <pattern>".

ches commented 8 years ago

I agree this would be a nicer experience.

One of the problems that makes this less simple than it might seem is that, if you're using ack.vim's support for Dispatch.vim to search asynchronously, I believe there's no way of knowing when the search is finished and Dispatch has the quickfix list ready. If we knew that then we could check if the list is empty before displaying it.

I may be misunderstanding that—there is an event fired, but I think it only works if the quickfix is eagerly displayed before results are ready, you can't wait to decide whether to display the list at all. This is how ack.vim behaves already when using Dispatch because of this limitation. We could subsequently hide the list if it turns out to be empty, and I'm okay with that, but it's kinda janky.

I'll try to take a further look at this, because I haven't confirmed it.

So if you're not using Dispatch, this should be easy to implement. But if you are, it's not, and having the plugin cleanly handle both cases with near-uniformity isn't something I've worked out yet.

jonashaag commented 8 years ago

I'm not using dispatch

ches commented 8 years ago

But other people are (including myself), so my point is that a solution needs to support both cases without becoming too much of a mess to maintain.

It would be a nice UX improvement, but it's not actually broken behavior and most of the time I think people search for a term they're already looking at, so empty results are fairly rare. So I'm not really willing to introduce a lot of messy code for the small improvement, only if it's clean.

ches commented 8 years ago

Relevant 😞 : https://github.com/mhinz/vim-grepper/commit/c345137c336c531209a6082a6fcd5c2722d45773