Fix bug 298821: do the right thing with autocomplete whether or not the user types the protocol part of the URL.

This commit is contained in:
smfr%smfr.org 2005-07-22 00:26:38 +00:00
Родитель 37d06c859e
Коммит d121dd6192
1 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -567,12 +567,16 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
// reset the insertion point.
NSString *result = [mDataSource resultString:aRow column:@"col1"];
// don't match letters in the protocol
// figure out where to start the match, depending on whether the user typed the protocol part
int protocolLength = 0;
NSURL* resultURL = [NSURL URLWithString:result];
NSURL* searchURL = [NSURL URLWithString:mSearchString];
if (resultURL)
protocolLength = [[resultURL scheme] length];
{
if (([[searchURL scheme] length] == 0) || ![[searchURL scheme] isEqualToString:[resultURL scheme]])
protocolLength = [[resultURL scheme] length];
}
NSRange matchRange = [result rangeOfString:mSearchString options:NSCaseInsensitiveSearch range:NSMakeRange(protocolLength, [result length] - protocolLength)];
if (matchRange.length > 0 && matchRange.location != NSNotFound) {
unsigned int location = matchRange.location + matchRange.length;