Fix DCHECK with Trailing Slash.

A DCHECK was being hit when a full URL with a scheme was entered and the user typed a slash. The slash was being removed by FormatURLWithOffsets but the inline_autocomplete_offset was not being adjusted to account for the removed slash.

BUG=112226
TEST=Ran unit tests.
TBR=pkasting@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9307027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120080 0039d316-1c4b-4281-b951-d872f2087c98
parent 62151053
......@@ -128,10 +128,10 @@ AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch(
AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(),
net::FormatUrlWithOffsets(info.url(), languages_, format_types,
net::UnescapeRule::SPACES, NULL, NULL, &offsets));
match.contents = net::FormatUrl(info.url(), languages_, format_types,
net::UnescapeRule::SPACES, NULL, NULL, NULL);
history::TermMatches new_matches =
ReplaceOffsetsInTermMatches(history_match.url_matches, offsets);
match.contents = net::FormatUrl(info.url(), languages_, format_types,
net::UnescapeRule::SPACES, NULL, NULL, NULL);
match.contents_class =
SpansFromTermMatch(new_matches, match.contents.length(), true);
......@@ -141,7 +141,11 @@ AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch(
DCHECK(!new_matches.empty());
match.inline_autocomplete_offset = new_matches[0].offset +
new_matches[0].length;
DCHECK_LE(match.inline_autocomplete_offset, match.fill_into_edit.length());
// The following will happen if the user has typed an URL with a scheme
// and the last character typed is a slash because that slash is removed
// by the FormatURLWithOffsets call above.
if (match.inline_autocomplete_offset > match.fill_into_edit.length())
match.inline_autocomplete_offset = match.fill_into_edit.length();
}
// Format the description autocomplete presentation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment