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

Treat underscore as word/path-segment separator? #41

Open
matthewd opened this issue Nov 19, 2017 · 1 comment
Open

Treat underscore as word/path-segment separator? #41

matthewd opened this issue Nov 19, 2017 · 1 comment

Comments

@matthewd
Copy link

Starting from activerecord/lib/active_record/connection_adapters/abstract_adapter.rb, I typed pool.

I wanted to find activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, but the top results were:

> activerecord/test/cases/pooled_connections_test.rb
> activerecord/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb
> activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb
> activestorage/test/controllers/previews_controller_test.rb
> activestorage/app/controllers/active_storage/previews_controller.rb
> actionview/test/fixtures/actionpack/test/potential_conflicts.erb
> actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb
> activesupport/lib/active_support/core_ext/range/overlaps.rb
> actionpack/test/fixtures/public/foo/other-index.html
> actionpack/test/fixtures/公共/foo/other-index.html
> railties/lib/rails/generators/rails/app/templates/config/databases/oracle.yml.tt
> activesupport/lib/active_support/logger.rb

The first match does contain a contiguous pool at the start of the filename, so it's not unreasonable that it came first. And the second has a split prefix match for po*/o*/l*. But the rest are pretty spread-out arbitrary single-letter substring matches.

Given the path similarity, I expected my target to be at the top of the list, followed by activerecord/lib/active_record/connection_adapters/statement_pool.rb (shorter, but no abstract).

cp and spoo are sufficient to get those two files, respectively, to the top while using their first character.

I know different people/projects use underscores (and similar characters) in different ways, and sometimes treating it as a full word separator equal to / could give equally surprising results in the opposite direction. Perhaps the list of separators could be configurable?


❤️ 💚 💙 💛 💜

Thanks so much for cpsm! Its match quality has completely changed my mind about the usefulness of fuzzy finders -- and it's only because of that "always knows what I mean" awesomeness that I'm opening this issue to report where it's tripped me up.

@nixprime
Copy link
Owner

_ is actually recognized as a word separator, which is why cp and spoo work. The problem is that cpsm isn't very good at matching queries that don't at least match at the beginning of the basename, because in the current implementation word matching is a bit of hack to prevent matching from being exponential-time in the length of the query. I have some ideas on how to improve this, but it'll probably involve another matcher redesign.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants