insanum / sncli

Simplenote CLI
MIT License
397 stars 34 forks source link

Google style search is case sensitive on tags? #31

Closed shankargopal closed 5 years ago

shankargopal commented 8 years ago

I have just started using this wonderful program, with help from you all, and hope to make it a main part of my workflow.

One small issue has appeared. The README.md says that google style search is case insensitive. But it appears to be case sensitive when searching tags. I am not able to attach a screenshot (Github keeps saying "Something went really wrong") but I am able to reproduce this.

Is there any way of toggling a case insensitive search, or of making that the default?

Thanks again!

samuelallan72 commented 8 years ago

After looking through the code, I can tell you that with the google-style search, words and other patterns are matched case-insensitively, but tags are matched case-sensitively. There's currently no way to configure that (apart from modifying the code yourself).

I'd be interested to hear from @insanum as to whether it would be useful to add a configuration option or flag in the search string to toggle sensitivity. The regex search is also case sensitive - ability to add flags for toggling case-sensitivity there might be handy too.

shankargopal commented 8 years ago

Can you tell me where in the code this functionality occurs? I know Python but am not confident of my abilities to find the correct location of this myself. If you'd like I'll make the change and submit a patch. It seems to me that while a toggle switch is the ideal option, in the absence of that tag search in google style searching should also be case insensitive, to be consistent with text searching and with the documentation.

On Thursday, October 6, 2016, Samuel Walladge notifications@github.com wrote:

After looking through the code, I can tell you that with the google-style search, words and other patterns are matched case-insensitively, but tags are matched case-sensitively. There's currently no way to configure that (apart from modifying the code yourself).

I'd be interested to hear from @insanum https://github.com/insanum as to whether it would be useful to add a configuration option or flag in the search string to toggle sensitivity. The regex search is also case sensitive - ability to add flags for toggling case-sensitivity there might be handy too.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/insanum/sncli/issues/31#issuecomment-251835752, or mute the thread https://github.com/notifications/unsubscribe-auth/ABXBeYwTO1jzJ4zXYVHZivqfYtVv2WDGks5qxD3ygaJpZM4KOamB .

samuelallan72 commented 8 years ago

The actual matching happens in the _helper_gstyle_tagmatch and _helper_gstyle_wordmatch functions located in /simplenote_cli/notes_db.py. You should be able to find where those functions are called to follow the tree up from there.

Yes definitely feel free to submit pull requests for any changes you make. 😄

Personally I think features that could be implemented to improve search could include:

insanum commented 8 years ago

I think these are great ideas. Bring on the pull requests! :-)

samuelallan72 commented 7 years ago

Also it seems that the current tag matching uses startswith, so a search for tag:foo would match notes with tags foo, foobar, and foobaz. Perhaps the functionality by default should be either exact tag match (so foo would only match notes with the foo tag), or use in (so foo would match foo and barfoobar). Thoughts?

samuelallan72 commented 7 years ago

I have now implemented an optional case-insensitive flag for regex searches, and tag matches in the google style search is case-insensitive.

shankargopal commented 7 years ago

Many, many thanks. I had in fact implemented case insensitive tag matching in the google style searching on my own machine, but never managed to make a pull request. Apologies for that.

On the other question, I had noticed that, and felt that substring searching (using 'in') for tags rather than exact / startswith would be best - only because many people automatically assume that substring searching will occur. I didn't do the coding though.

On Sun, 22 Jan 2017 19:54:33 -0800 Samuel Walladge notifications@github.com wrote:

I have now implemented an optional case-insensitive flag for regex searches, and tag matches in the google style search is case-insensitive.

samuelallan72 commented 7 years ago

Agreed, in feels more intuitive. Implemented.

@shankargopal if you're happy that your original problem has been resolved, can we close this issue?