After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 737620 - Search provider matches plain numbers
Search provider matches plain numbers
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: general
3.14.x
Other Linux
: Normal normal
: ---
Assigned To: Michael Catanzaro
gcalctool maintainers
Depends on:
Blocks:
 
 
Reported: 2014-09-29 20:22 UTC by Marcus Lundblad
Modified: 2014-10-26 20:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
search-provider: don't match plain numbers (1.32 KB, patch)
2014-10-23 20:22 UTC, Marcus Lundblad
reviewed Details | Review
search-provider: don't match plain numbers (2.44 KB, patch)
2014-10-26 18:58 UTC, Marcus Lundblad
none Details | Review
search-provider: don't match plain numbers (2.00 KB, patch)
2014-10-26 20:17 UTC, Michael Catanzaro
committed Details | Review

Description Marcus Lundblad 2014-09-29 20:22:37 UTC
The new shell search provider is a really nice addition in 3.14.
One thing that struck me as a bit odd, is that it matches on "plain" number (i.e. without any operators or such).
Maybe it should filter out search queries just containing digits (I think this might be done in the can_parse function in search-provider.vala, before calling out to the gnome-terminal binary to get equation results).

Regards,
Marcus
Comment 1 André Klapper 2014-09-30 07:58:19 UTC
Hmm, why dio you think that is "a bit odd"? :)
Comment 2 Marcus Lundblad 2014-09-30 19:54:16 UTC
Well, if I press super and type, let's say, 4711, I probably wanted to search for some content matching this string. I likely already know that 4711 equals 4711 :-)
Comment 3 Matthias Clasen 2014-10-01 11:16:06 UTC
to catch cases like 4711, you could just look for input == output
Comment 4 Marcus Lundblad 2014-10-23 20:22:14 UTC
Created attachment 289234 [details] [review]
search-provider: don't match plain numbers

Filter out plain number from search results, so that entering just a number
doesn't show up as the number equaling itself.
Comment 5 Michael Catanzaro 2014-10-23 23:32:59 UTC
Review of attachment 289234 [details] [review]:

I think this almost works, but we also have to account for the fact that the input could contain a thousands separator. I'm pretty sure double.parse (which "behaves like strtod() does in the C locale") is not going to cut it there.

This also breaks the simple input == output test. E.g.

$ gnome-calculator --solve 1,2345
12345

I think this patch would work in all cases if it simply stripped all instances of the thousands separator from the input string before the check. Can anyone think of anything I've missed?
Comment 6 Michael Catanzaro 2014-10-23 23:35:44 UTC
Check handle_local_options() in gnome-calculator.vala to see how to get the thousands separator from nl_langinfo() and easily remove all instances of it from a string using string.replace().
Comment 7 Marcus Lundblad 2014-10-26 18:58:51 UTC
Created attachment 289376 [details] [review]
search-provider: don't match plain numbers

Filter out plain number from search results, so that entering just a number
doesn't show up as the number equaling itself. Also handle locale-specific
thousands separator and decimal separator.
Comment 8 Michael Catanzaro 2014-10-26 20:17:26 UTC
Looks good; I've rebased this on top of master.

The following fix has been pushed:
165cf3d search-provider: don't match plain numbers
Comment 9 Michael Catanzaro 2014-10-26 20:17:29 UTC
Created attachment 289380 [details] [review]
search-provider: don't match plain numbers

Filter out plain number from search results, so that entering just a number
doesn't show up as the number equaling itself. Also handle locale-specific
thousands separator and decimal separator.