Bug 781617 - autoFill should respect user's input.
r=unfocused
--- a/suite/common/places/nsPlacesAutoComplete.js
+++ b/suite/common/places/nsPlacesAutoComplete.js
@@ -1398,16 +1398,23 @@ urlInlineComplete.prototype = {
untrimmedDomain = query.getString(1);
}
} finally {
query.reset();
}
if (hasDomainResult) {
// We got a match for a domain, we can add it immediately.
+ // If the untrimmed value doesn't preserve the user's input just
+ // ignore it and complete to the found domain.
+ if (untrimmedDomain &&
+ !untrimmedDomain.toLowerCase().contains(this._originalSearchString.toLowerCase())) {
+ untrimmedDomain = null;
+ }
+
// TODO (bug 754265): this is a temporary solution introduced while
// waiting for a propert dedicated API.
result.appendMatch(this._strippedPrefix + domain, untrimmedDomain);
this._finishSearch();
return;
}
}
@@ -1508,19 +1515,27 @@ urlInlineComplete.prototype = {
separatorIndex += this._currentSearchString.length;
if (url[separatorIndex] == "/") {
separatorIndex++; // Include the "/" separator
}
url = url.slice(0, separatorIndex);
}
// Add the result.
+ // If the untrimmed value doesn't preserve the user's input just
+ // ignore it and complete to the found url.
+ let untrimmedURL = prefix + url;
+ if (untrimmedURL &&
+ !untrimmedURL.toLowerCase().contains(this._originalSearchString.toLowerCase())) {
+ untrimmedURL = null;
+ }
+
// TODO (bug 754265): this is a temporary solution introduced while
// waiting for a propert dedicated API.
- this._result.appendMatch(this._strippedPrefix + url, prefix + url);
+ this._result.appendMatch(this._strippedPrefix + url, untrimmedURL);
// handleCompletion() will cause the result listener to be called, and
// will display the result in the UI.
},
handleError: function UIC_handleError(aError)
{
Components.utils.reportError("URL Inline Complete: An async statement encountered an " +