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

case insensitive exact content search #546

Open
karottenreibe opened this issue Apr 27, 2022 · 3 comments
Open

case insensitive exact content search #546

karottenreibe opened this issue Apr 27, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@karottenreibe
Copy link

Searching in file names is case-insensitive by default. Searching content with c/ is case-sensitive by default.
Intuitively, I'd have expected c/ to also be case insensitive. Adding /i at the end does not turn on case sensitivity as it does for cr/.

broot 1.11.1 on Ubuntu

Suggestions

I see several possible solutions (the one I like most ordered first):

  • c/ could be "smart" by default, like vim with set smartcase: If all chars are lowercase in the search, search case-insensitively. If at least one is uppercase, search case-sensitively. This works very well for me in vim, matches my intuitive expectation and makes it trivial to turn on case sensitive search
  • if this is not possible, c/ could be case insensitive by default
  • If none of the above two can be implemented, c/ should at least accept the /i flag that cr/ accepts to turn case-sensitivity off
@karottenreibe karottenreibe added the enhancement New feature or request label Apr 27, 2022
@Canop
Copy link
Owner

Canop commented May 1, 2022

There are two kinds of content searches:

  1. exact search, fast but absolutely not tunable, set to c/ by default
  2. regular expression: a little less fast but very configurable, set to cr/ by default

Is there a reason for not using cr/ in your case ? You can even remap it to a one letter prefix if you want.

@karottenreibe
Copy link
Author

karottenreibe commented May 1, 2022

@Canop thanks for your reply! Using cr/ means that I have to be aware of regex special characters while searching. While not a backbreaking problem, I find this uncomfortable. Also, my search is not iterative, since it only really does what I want once I have added /i at the end. So "iterative search term refinement" is a lot more clumsy:

  • enter partial search, e.g. cr/asdf
  • append /i
  • now I see first actual results
  • move cursor left by two characters
  • keep refining search

This is much nicer with smartcasing. Smartcasing was also what I intuitively expected c/ to do (being used to it from vim).

Is there any use case where a "smartcased" c/ search would not be wanted?

As to performance, is case-insensitiveness a big performance problem for content search? I'd have though there should be ways to make case insensitive search fast, e.g. lowercasing the searched file contents (should be O(n) I guess, but haven't measured actual performance of lowercasing). I'd be happy to research this, if you think it's a problem.

@Canop
Copy link
Owner

Canop commented May 2, 2022

OK, I understand why you don't find cr/ ideal.

I won't change the existing fast content search c/ but I'll probably add another search engine for easier case insensitive search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants