GNOME Bugzilla – Bug 737620
Search provider matches plain numbers
Last modified: 2014-10-26 20:17:29 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
Hmm, why dio you think that is "a bit odd"? :)
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 :-)
to catch cases like 4711, you could just look for input == output
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.
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?
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().
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.
Looks good; I've rebased this on top of master. The following fix has been pushed: 165cf3d search-provider: don't match plain numbers
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.