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 706724 - Bold matches against search string in search popup
Bold matches against search string in search popup
Status: RESOLVED FIXED
Product: gnome-maps
Classification: Applications
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-maps-maint
gnome-maps-maint
Depends on: 706653
Blocks:
 
 
Reported: 2013-08-24 21:59 UTC by Jonas Danielsson
Modified: 2013-08-30 14:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
MainWindow: Bold string matches in search popup (1.98 KB, patch)
2013-08-24 22:00 UTC, Jonas Danielsson
none Details | Review
MainWindow: Bold string matches in search popup v2 (5.86 KB, patch)
2013-08-24 22:36 UTC, Jonas Danielsson
none Details | Review
MainWindow: Bold string matches in search popup v3 (2.20 KB, patch)
2013-08-24 22:43 UTC, Jonas Danielsson
none Details | Review
MainWindow: Bold string matches in search popup v4 (2.23 KB, patch)
2013-08-24 23:15 UTC, Jonas Danielsson
reviewed Details | Review
MainWindow: Bold string matches in search popup (2.18 KB, patch)
2013-08-27 14:37 UTC, Jonas Danielsson
none Details | Review
MainWindow: Bold string matches in search popup v6 (2.41 KB, patch)
2013-08-28 06:49 UTC, Jonas Danielsson
none Details | Review
MainWindow: Bold string matches in search popup v7 (2.49 KB, patch)
2013-08-28 13:22 UTC, Jonas Danielsson
accepted-commit_after_freeze Details | Review
MainWindow: Bold string matches in search popup (2.60 KB, patch)
2013-08-29 13:52 UTC, Zeeshan Ali
none Details | Review
MainWindow: Bold string matches in search popup (2.58 KB, patch)
2013-08-30 08:08 UTC, Jonas Danielsson
committed Details | Review
MainWindow: Abort if no search results was found (1007 bytes, patch)
2013-08-30 13:04 UTC, Jonas Danielsson
committed Details | Review

Description Jonas Danielsson 2013-08-24 21:59:35 UTC
To show better why a search result was included, lets bold the substring that matches against the search string.
Comment 1 Jonas Danielsson 2013-08-24 22:00:22 UTC
Created attachment 253025 [details] [review]
MainWindow: Bold string matches in search popup
Comment 2 Mattias Bengtsson 2013-08-24 22:26:32 UTC
Review of attachment 253025 [details] [review]:

Otherwise fine!

::: src/mainWindow.js
@@ +235,3 @@
 
+    _boldMatch: function(description) {
+        let searchString = this._searchEntry.get_text().toLowerCase();

Could we do this once? Not a huge thing but not necessary to run toLowerCase each time.

@@ +240,3 @@
+        if (index !== -1) {
+            let substring = description.substring(index,
+                                                  index + searchString.length);

Please add a comment on why we need to do substring + replace instead of just replace. I understand it but would be good for the next guy to also understand. :)
Comment 3 Jonas Danielsson 2013-08-24 22:36:55 UTC
Created attachment 253026 [details] [review]
MainWindow: Bold string matches in search popup v2
Comment 4 Jonas Danielsson 2013-08-24 22:43:58 UTC
Created attachment 253027 [details] [review]
MainWindow: Bold string matches in search popup v3
Comment 5 Jonas Danielsson 2013-08-24 23:15:36 UTC
Created attachment 253029 [details] [review]
MainWindow: Bold string matches in search popup v4

Added escaping of markup and some renaming of vars.
Comment 6 Zeeshan Ali 2013-08-27 13:30:47 UTC
Review of attachment 253029 [details] [review]:

::: src/mainWindow.js
@@ +239,3 @@
+
+        if (index !== -1) {
+            let substring = description.substring(index,

Can we be sure that index remains the same regardless of case in ever locale?

@@ +253,3 @@
 
+        // Lower case to match case insensitive
+        let searchStringLower = this._searchEntry.get_text().toLowerCase();

Another place where use of props would make for slightly more readable code.
Comment 7 Jonas Danielsson 2013-08-27 14:20:17 UTC
Review of attachment 253029 [details] [review]:

::: src/mainWindow.js
@@ +239,3 @@
+
+        if (index !== -1) {
+            let substring = description.substring(index,

I have no idea :(

There is a toLocaleLowerCase() but I'm not sure it helps.

@@ +253,3 @@
 
+        // Lower case to match case insensitive
+        let searchStringLower = this._searchEntry.get_text().toLowerCase();

Agreed!
Comment 8 Jonas Danielsson 2013-08-27 14:35:38 UTC
Review of attachment 253029 [details] [review]:

::: src/mainWindow.js
@@ +239,3 @@
+
+        if (index !== -1) {
+            let substring = description.substring(index,

Ok so reading on it, in order for the users locale to have affect in you should use the toLocaleLowerCase. And for Turkish it will have an effect on the length of the different cases. So we should use toLocaleLowerCase that should behave the same as toLowerCase otherwise. Good Catch. (reference: http://code.google.com/p/v8/issues/detail?id=2196, even tho that is about v8 not handling it correctly)
Comment 9 Jonas Danielsson 2013-08-27 14:37:30 UTC
Created attachment 253260 [details] [review]
MainWindow: Bold string matches in search popup

* use javascript String.bold() method to insert <b> and </b>

* use toLocaleLowerCase to be safe in Turkish locale
Comment 10 Zeeshan Ali 2013-08-27 15:54:48 UTC
Review of attachment 253029 [details] [review]:

::: src/mainWindow.js
@@ +239,3 @@
+
+        if (index !== -1) {
+            let substring = description.substring(index,

gjs> "İ".length
1
gjs> "İ".toLowerCase().length
1
gjs> "İ".toLocaleLowerCase().length
2

That makes me think that we actually should not use toLocaleLowerCase().
Comment 11 Jonas Danielsson 2013-08-28 06:49:35 UTC
Created attachment 253345 [details] [review]
MainWindow: Bold string matches in search popup v6

Thanks for investigating!

* Use toLowerCase

* rebased against master
Comment 12 Jonas Danielsson 2013-08-28 13:22:49 UTC
Created attachment 253379 [details] [review]
MainWindow: Bold string matches in search popup v7

* rebased against bug#706653
Comment 13 Zeeshan Ali 2013-08-28 13:38:58 UTC
Review of attachment 253379 [details] [review]:

Looks good but I didn't ask for freeze exception for this one. :(
Comment 14 Zeeshan Ali 2013-08-29 13:52:43 UTC
Created attachment 253508 [details] [review]
MainWindow: Bold string matches in search popup

Rebased on current git master.
Comment 15 Jonas Danielsson 2013-08-30 08:06:44 UTC
Review of attachment 253508 [details] [review]:

::: src/mainWindow.js
@@ +265,1 @@
+        model.clear();

This happens in onSearchActivate() now
Comment 16 Jonas Danielsson 2013-08-30 08:06:52 UTC
Review of attachment 253508 [details] [review]:

::: src/mainWindow.js
@@ +265,1 @@
+        model.clear();

This happens in onSearchActivate() now
Comment 17 Jonas Danielsson 2013-08-30 08:08:35 UTC
Created attachment 253586 [details] [review]
MainWindow: Bold string matches in search popup

No need to clear model twice.
Comment 18 Zeeshan Ali 2013-08-30 12:19:49 UTC
Review of attachment 253586 [details] [review]:

If not clearing the model is the only change and this works and is on top of git master (hopefully you found my rebasing useful? :P), ACK
Comment 19 Zeeshan Ali 2013-08-30 12:45:48 UTC
Attachment 253586 [details] pushed as 8102fe2 - MainWindow: Bold string matches in search popup
Comment 20 Jonas Danielsson 2013-08-30 13:04:43 UTC
Created attachment 253604 [details] [review]
MainWindow: Abort if no search results was found

Commit: 8102fe2 MainWindow: Bold string matches in search popup, removed the check for when no search results were found. Lets reinstate it.
Comment 21 Zeeshan Ali 2013-08-30 14:37:37 UTC
Comment on attachment 253604 [details] [review]
MainWindow: Abort if no search results was found

Attachment 253604 [details] pushed as 34daf30 - MainWindow: Abort if no search results was found