From 0db7c900516880c9f4378f329042d56b2f234c58 Mon Sep 17 00:00:00 2001 From: "pamg.bugs%gmail.com" Date: Thu, 15 Jun 2006 21:53:09 +0000 Subject: [PATCH] Bug 246237: Fix various navigation key + autoFill issues. Patch by pkasting@google.com, r=mconnor, sr+a181=benjamin --- .../autocomplete/src/nsAutoCompleteController.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp b/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp index e6c145a2cacf..808dc9b86386 100644 --- a/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp +++ b/toolkit/components/autocomplete/src/nsAutoCompleteController.cpp @@ -461,13 +461,21 @@ nsAutoCompleteController::HandleKeyNavigation(PRUint16 aKey, PRBool *_retval) if (selectedIndex >= 0) { // The pop-up is open and has a selection, take its value nsAutoString value; - if (NS_SUCCEEDED(GetResultValueAt(selectedIndex, PR_TRUE, value))) - CompleteValue(value, PR_FALSE); + if (NS_SUCCEEDED(GetResultValueAt(selectedIndex, PR_TRUE, value))) { + mInput->SetTextValue(value); + mInput->SelectTextRange(value.Length(), value.Length()); + } } // Close the pop-up even if nothing was selected ClearSearchTimer(); ClosePopup(); } + // Update last-searched string to the current input, since the input may + // have changed. Without this, subsequent backspaces look like text + // additions, not text deletions. + nsAutoString value; + mInput->GetTextValue(value); + mSearchString = value; } return NS_OK; @@ -1106,8 +1114,6 @@ nsAutoCompleteController::RevertTextValue() if (!cancel) mInput->SetTextValue(oldValue); - - mSearchString.Truncate(0); return NS_OK; }