Closed Bug 739751 Opened 12 years ago Closed 12 years ago

in-the-middle autocomplete unexpectedly appears in urlbar ("searchstring >> full string")

Categories

(Toolkit :: Autocomplete, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: Margaret, Assigned: mak)

References

(Depends on 1 open bug)

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

I find this happens with these same steps, regardless of search string/domain:

1) type a few characters (e.g. "dr")
2) press right arrow to autocomplete domain (results in "http://dropbox.com/" in urlbar)
3) press space (results in "http://dropbox.com/  >> dropbox.com/" in urlbar)

If I press the right arrow again (or press enter to submit the search) it does not replace my inital search string, it just searches for "http://dropbox.com/  >> dropbox.com/".
I'll start by making a testcase, though if anyone wants to steal this, it's free, I'm just assigning to not lose it.
Assignee: nobody → mak77
This is the first issue:

1. you are searching for "dropbox.com/ " where the actual value is "dropbox.com/". 2. The search trims the search term and returns "dropbox.com/"
3. nsAutoCompleteController::CompleteValue does a StringBeginsWith(aValue, mSearchString), this fails cause searchstring is longer
4. it then enters the else, that tries to extract a scheme, but we trimmed out http, so it just decides we are completing a simple word from the middle.

still investigating what happens when you confirm.
looks like we enter GetDefaultCompleteValue with aResultIndex == -1, we try to loop through mResults, but it's empty
Blocks: 566489
Keywords: regression
hm, nvm comment 3. in the end it's just that we add a match shorter than the searchstring and that confuses completeDefaultIndex.
Status: NEW → ASSIGNED
Attached patch patch v1.0 (obsolete) — Splinter Review
I think makes sense to avoid trying to inline autocomplete anything with spaces, since we are autocompleting urls, this ensures we don't end up uselessly tokenizing and then passing fancy results back to completeDefaultValue.
Attachment #610919 - Flags: review?(gavin.sharp)
Attached patch patch v1.1Splinter Review
oops the comment was a bit unclean.
Attachment #610919 - Attachment is obsolete: true
Attachment #610919 - Flags: review?(gavin.sharp)
Attachment #610920 - Flags: review?(gavin.sharp)
Comment on attachment 610920 [details] [diff] [review]
patch v1.1

>diff --git a/toolkit/components/places/nsPlacesAutoComplete.js b/toolkit/components/places/nsPlacesAutoComplete.js

>+    // Don't try to autofill if the search term includes any whitespace.
>+    // This may confuse completeDefaultIndex cause the MATCH_AUTOCOMPLETE
>+    // tokenizer ends up trimming the search string and returning a value
>+    // that doesn't match it, or is even shorter.

What is MATCH_AUTOCOMPLETE? This solution seems reasonable, but I have to admit I still don't fully understand the cause of the bug. Should we also have a more complete solution that fixes this problem more generally (in the controller?).
Attachment #610920 - Flags: review?(gavin.sharp)
MATCH_AUTOCOMPLETE is a SQL function that takes search terms, tokenize them, and compare them to url, tags and title.
The controller is doing the right thing, it is passing us the search string, and would be wrong for it to strip spaces or tokenize, since it can't know what kind of resources the search is searching.
I don't think controller can make any assumption on the search, some search may want to retain and search for spaces.
The problem here is that the specific search applies transformation to the search string, and that transformation ends up returning a result that is shorter than the search string, that doesn't make sense.
Comment on attachment 610920 [details] [diff] [review]
patch v1.1

r=me with the comment fixed to mention AUTOCOMPLETE_MATCH
Attachment #610920 - Flags: review+
fixed the comment and pushed
https://hg.mozilla.org/integration/mozilla-inbound/rev/a6527fdc59f4
Flags: in-testsuite+
OS: Mac OS X → All
Hardware: x86 → All
Target Milestone: --- → mozilla14
seems to have caused a 12.1% regresssion of JM on kraken-astar
https://hg.mozilla.org/mozilla-central/rev/a6527fdc59f4
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Depends on: 1328037
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: