Skip to content

Case sensitive patterns in SearchNote #34

Closed
ashinkarov opened this Issue Apr 2, 2013 · 3 comments

2 participants

@ashinkarov

When searching a word that exists in some note, but has a different case of some symbols, the SearchNote is doing this:

Error detected while processing function xolox#notes#search..14_internal_search..14_vimgrep
_wrapper:
line 8:
E480: No match: finalizing
Error detected while processing function xolox#notes#search..14_internal_search:
line 30:
E171: Missing :endif
Error detected while processing function xolox#notes#search:
line 20:
E171: Missing :endif

In this example I had a note that starts with a word 'Finalizing' and the command that I have executed was 'SearchNote finalizing'. Funnily enough, the tab-completion suggested 'finalizing' without any problems.

It seems that vimgrep does not use case-insensetive search, and the try-finally wrapper in vimgrep_wrapper does not catch the failure.

@xolox
Owner
xolox commented Apr 18, 2013

I can reproduce this when I :set noignorecase but I'm not sure what's the best way to fix it:

  1. Always force keyword searches in the vim-notes plug-in to be case insensitive.
  2. Properly enable case sensitive keyword searches by passing the &ignorecase setting to the Python script that performs the search.

Which would you prefer? I think case insensitive searching (option 1) is more intuitive for beginners. On the other hand I will bet that if I go with option 1 at some point someone will complain they can't do case sensitive searches :-)

@ashinkarov

Well, honestly speaking, I would prefer the second option.

But why is it happening at all? Why it overpasses try-catch construction in the wrapper? I would expect that the search would just return with false, and then I would be notified that the pattern was not found.

@xolox xolox added a commit that referenced this issue Apr 21, 2013
@xolox Support case sensitive keyword searches (issue #34)
This change breaks backwards compatibility with the previous keyword
index format, however the Python script will recreate the index in
the new format and everything should be fine.

Also this change enlarges the file size of the index, but I have ideas
on how to speed up the search-notes.py script (to be continued :-).
af27b21
@xolox
Owner
xolox commented Apr 21, 2013

Hi Artem,

The bug you reported about case sensitive keyword searches should now be fixed. I had to change the format of the index file so when you run the new version it will have to recreate the index (this should happen automatically). After that it should work as expected when Vim's ignorecase option is set to false.

About why this happened: There is no try/catch block, that's a try/finally block, which is something different. It doesn't catch or silence errors (exceptions), it just makes sure something happens no matter whether an operation is successful or raises errors. Anyway, in the end it was a bug in the plug-in, so thanks for bringing it to my attention :-).

Happy Vimming!

- Peter

PS. Closing this issue now as the problem should be resolved. If it's not, feel free to reopen this issue.

@xolox xolox closed this Apr 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.