lucc / khard

Console vcard client
https://khard.readthedocs.io/en/latest/
GNU General Public License v3.0
600 stars 65 forks source link

Incomplete search results when using a list modifier #243

Closed elumbella closed 4 years ago

elumbella commented 4 years ago

I'm trying to get full search results for usage with mutt. In my case, I want to find all contacts belonging to a certain category CAT. All of them have

Category: CAT

in their respective vCard files.

khard CAT

yields the desired results, whereas

khard email CAT

doesn't. It seems as if only the visible fields are searched (i.e. Name, Type and E-Mail)l. This is still the case with search_in_source_files = yes in khard.conf as well as adding the flag --search-in-source-files.

lucc commented 4 years ago

I added 970af75 but can not reproduce your problem. Can you please explain what I need to do to see the bug. If possible you should give a minimal example including vcards, config and commands you use.

elumbella commented 4 years ago

Alright, I tested again. It seems, khard has an issue with the term CAT as I get very weird results when using this specific word. Possibly it is giving me all contacts that have some category. I tried reproducing with another string and this reproduces. 8y7rgopzm4rkvdns221iqmqzhjimuzib57jn.vcf, an example contact

BEGIN:VCARD VERSION:3.0 UID:8y7rgopzm4rkvdns221iqmqzhjimuzib57jn CATEGORIES:FBY FN:test person N:person;test;;; REV:202001dT152538Z END:VCARD

khard.conf

[addressbooks] [[nextcloud]] path = ~/.contacts/nextcloud/contacts

[general] editor = nvim merge_editor = vimdiff default_action = list show_nicknames = no

[vcard] search_in_source_files = yes

khard FBY outputs the test person, whereas khard email FBY says Found no email addresses

edit: haven't tried that with your commit yet

d7415 commented 4 years ago

khard FBY outputs the test person, whereas khard email FBY says Found no email addresses

But that contact doesn't have an email address, so that would be expected.

lucc commented 4 years ago

If the contact does not have an email address it is not listed when using khard email. That is expected. What is an email program going to do with a contact that does not have an email address?

Why "CAT" is special:

  1. case is ignored
  2. in order to match a vcard against some search term the rendered version of the vcard is produced (the one you see with khard show ...). If the vcard has a category that is titled by the text "Categories" which obviously matches "CAT".
elumbella commented 4 years ago

I added an email address to the test contact and it now seems to work. The weird thing is, it doesn't work with my own contacts. I'm using the category FBX. FBY somehow works fine but FBX doesn't.

lucc commented 4 years ago

so what exactly should happen with the fbx category and what is happening instead? The more specific the better ...

elumbella commented 4 years ago

Just as mentioned before. Contacts with the category fbx show up with khard fbx but don't with khard email fbx

elumbella commented 4 years ago

Alright, I think I have it narrowed down: khard <term> shows all contacts which contain <term> somewhere. khard email <term> only shows contacts, where <term> is somewhere in the name or the email address. It is thus impossible to search for categories (or, for that matter, anything else besides name and email address) when using the email argument

lucc commented 4 years ago

@elumbella I tried to update the tests according to your last comment. See the commit f366f4. I am doing this:

Either I am missunderstanding you your description or I don't know what. Can you please write a complete test case that I can execute on travis? The mentioned commit still passes.

elumbella commented 4 years ago

I am very confused... You are right, your tests pass on my system as well. It seems to fail only with the literal category "fby". Can you try that string as a category? If it this specific string that isn't working, then I have absolutely no clue what could be wrong. As mentioned before, the string "fby" somehow works...

lucc commented 4 years ago

@elumbella as you can see here and here the tests still do not fail. I am sorry to say this very directly: I will not work on this issue any more until you provide a test case that can be made to fail on travis. And by that I mean, as a commit so that I do not have to code anything.

elumbella commented 4 years ago

I don't know what else to provide. I have provided everything that should be necessary. I don't know what more you want...

And by that I mean, as a commit so that I do not have to code anything.

How should I provide you with the scenario?

lucc commented 4 years ago

I don't know what else to provide. I have provided everything that should be necessary. I don't know what more you want...

I want something that actually fails when I try/execute it. So far you have given me many descriptions of what I as a human have to do. But every time I tried it I did not see anything failing.

So in order to prevent any misscommunication I want code that fails. Not instructions for a human but instructions for a computer. And in order to not get mixed up in differences between our private computers I want the code to fail on travis.

How should I provide you with the scenario?

As a test case in the test suite of khard.

By "test case" I mean a function like this: https://github.com/scheibler/khard/blob/970af752041daf779e6e2fe278b2b691458baec3/test/test_command_line_interface.py#L157-L167

So you open that file write some new function in there that tests your problem. Then you open a pull request for that change and we will see if the tests on travis fail.

elumbella commented 4 years ago

Hrm. I'm not a programmer, so that will be quite the challenge. I will see what I can do and report back once I have something (hopefully) appropriate to your specifications.