From 8bcb312ca77e0b6d7054d48d89af4a23d820cdfe Mon Sep 17 00:00:00 2001 From: "dean_tessman%hotmail.com" Date: Fri, 8 Aug 2003 02:38:24 +0000 Subject: [PATCH] 203754 - Bug in select code in Auto-Complete component patch eric@5stops.com git-svn-id: svn://10.0.0.236/trunk@145722 18797224-902f-48f8-a5cc-f745e15eee43 --- .../autocomplete/src/nsAutoCompleteController.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mozilla/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp b/mozilla/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp index d95faeacf52..6d705251b4d 100644 --- a/mozilla/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp +++ b/mozilla/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp @@ -113,9 +113,12 @@ nsAutoCompleteController::SetInput(nsIAutoCompleteInput *aInput) // Nothing more to do if the input was just being set to null. if (!aInput) return NS_OK; + + nsAutoString newValue; + mInput->GetTextValue(newValue); // Reset all search state members to default values - mSearchString.Truncate(0); + mSearchString = newValue; mEnterAfterSearch = PR_FALSE; mNeedToComplete = PR_FALSE; mDefaultIndexCompleted = PR_FALSE; @@ -944,7 +947,7 @@ nsAutoCompleteController::CompleteValue(nsString &aValue) mInput->SelectTextRange(mSearchString.Length(), aValue.Length()); } else { mInput->SetTextValue(mSearchString + Substring(aValue, mSearchString.Length()+findIndex, aValue.Length())); - mInput->SelectTextRange(mSearchString.Length(), -1); + mInput->SelectTextRange(mSearchString.Length(), aValue.Length() - findIndex); // XXX There might be a pref someday for doing it this way instead. // The textbox value does not match the beginning of the default value, so we