[gnome-documents] Casefold strings instead of lowercaseing when searching
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] Casefold strings instead of lowercaseing when searching
- Date: Thu, 16 Jan 2014 21:12:45 +0000 (UTC)
commit 41a211a9304963ca8d120684fa911c310ed04fb6
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Jan 15 10:50:28 2014 +0100
Casefold strings instead of lowercaseing when searching
Tracker's fn:lower-case calls u16_tolower or you_strToLower depending
on whether its libunistring or libicu is being used, which may case
Unicode strings to be "lowercased" differently than JavaScript's
String.prototype.toLowerCase.
In contrast tracker:case-fold calls g_utf8_casefold. Lets compare
outputs from the same function for the sake of predictability.
Moving the casefolding slightly lower down in the application has the
pleasant side-effect of not messing up the search string in the UI.
eg., if you enter "PASSAGE", preview a document, and come back to the
overview, then the search string in the UI would not become "passage".
https://bugzilla.gnome.org/show_bug.cgi?id=722246
src/search.js | 7 ++++---
src/searchbar.js | 2 +-
src/shellSearchProvider.js | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/search.js b/src/search.js
index a122c8b..3c36dc4 100644
--- a/src/search.js
+++ b/src/search.js
@@ -63,7 +63,8 @@ const SearchController = new Lang.Class({
},
getTerms: function() {
- let str = Tracker.sparql_escape_string(this._string);
+ let escaped_str = Tracker.sparql_escape_string(this._string);
+ let str = GLib.utf8_casefold(escaped_str, -1);
return str.replace(/ +/g, ' ').split(' ');
}
});
@@ -232,11 +233,11 @@ const SearchMatch = new Lang.Class({
getFilter: function() {
if (this.id == SearchMatchStock.TITLE)
return ('fn:contains ' +
- '(fn:lower-case (tracker:coalesce(nie:title(?urn), nfo:fileName(?urn))), ' +
+ '(tracker:case-fold(tracker:coalesce(nie:title(?urn), nfo:fileName(?urn))), ' +
'"%s")').format(this._term);
if (this.id == SearchMatchStock.AUTHOR)
return ('fn:contains ' +
- '(fn:lower-case (tracker:coalesce(nco:fullname(?creator), nco:fullname(?publisher))), ' +
+ '(tracker:case-fold(tracker:coalesce(nco:fullname(?creator), nco:fullname(?publisher))),
' +
'"%s")').format(this._term);
return '';
}
diff --git a/src/searchbar.js b/src/searchbar.js
index 7387570..0e0dd94 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -326,7 +326,7 @@ const OverviewSearchbar = new Lang.Class({
},
entryChanged: function() {
- let currentText = this._searchEntry.get_text().toLowerCase();
+ let currentText = this._searchEntry.get_text();
Application.searchController.disconnect(this._searchChangedId);
Application.searchController.setString(currentText);
diff --git a/src/shellSearchProvider.js b/src/shellSearchProvider.js
index 00505af..35961cb 100644
--- a/src/shellSearchProvider.js
+++ b/src/shellSearchProvider.js
@@ -318,7 +318,7 @@ const FetchIdsJob = new Lang.Class({
run: function(callback, cancellable) {
this._callback = callback;
this._cancellable = cancellable;
- searchController.setString(this._terms.join(' ').toLowerCase());
+ searchController.setString(this._terms.join(' '));
let query = queryBuilder.buildGlobalQuery();
Application.connectionQueue.add(query.sparql, this._cancellable, Lang.bind(this,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]