Case insensitive search #132
Labels
No Label
blocked
bug
build
documentation
duplicate
enhancement
finger
gemini
gopher
help wanted
http
in progress
invalid
local
needs-info
non-code
non-functional
non-urgent
question
release
rendering
suggestion
telnet
terminal
urgent
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sloum/bombadillo#132
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently the search function initiated by
/
is a verbatim match. It has been suggested by usernatpen
that providing an option for case insensitive search (or just defaulting to it) would be a better way to go.I am hesitant to add a full regex engine to Bombadillo, but case insensitive search should be very doable.
There is a version of this up currently on the branch
case-insensitive-search
. I do not like that this adds a little bit more weight to a part of the render chain/flow. However, it seems to be pretty negligible overhead (mostly the cost is converting every line in a file to lowercase for the search).I think there may be a slight problem with this version of case insensitivity: it will find case insensitive results on each line just fine. However, if there are two case versions of a word on a line it will only find the first one. So, for example:
In that brief bit of text the word
the
appears twice. Once at the beginning of the sentence and once toward the end. The first occasion has a capitalT
. When the match highlighting is done onlyThe
will be highlighted. Similarly:In the above example the first instance (
the
) would be highlighted, but notThe
.This has to do with the way search is carried out: Searching is done by finding the index of a word on each line. To add case insensitivity I just converted the search and the line to lower case when finding an index. I then take the index and add the length of the word to get the substring that was found and do a replace on the original line for all isntances of that substring to have the highlighting. As a result, it only highlights the matching word and not both versions even though if they appeared on separate lines they would both be highlighted.
I am, for the moment, ok with this compromise. I still think it is better than adding regex. The search functionality will still get you to any line with a match, leaving the user to visually grep the line as needed.
I'll wait a bit to create a PR on this so that it can sink in a bit and see how folks feel about it over a brief interval.