From 1c39a8100bac6dbdae57f1836b422c96b7846e24 Mon Sep 17 00:00:00 2001 From: Andreas Wagner Date: Sun, 23 Dec 2012 11:45:44 -0500 Subject: [PATCH] Bug 550175 - Check if a row in an autocomplete popup is selected while pressing DEL. r=mak --- .../components/autocomplete/nsAutoCompleteController.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/toolkit/components/autocomplete/nsAutoCompleteController.cpp b/toolkit/components/autocomplete/nsAutoCompleteController.cpp index d1acf20e2ec..9ed999d37e7 100644 --- a/toolkit/components/autocomplete/nsAutoCompleteController.cpp +++ b/toolkit/components/autocomplete/nsAutoCompleteController.cpp @@ -535,6 +535,12 @@ nsAutoCompleteController::HandleDelete(bool *_retval) int32_t index, searchIndex, rowIndex; popup->GetSelectedIndex(&index); + if (index == -1) { + // No row is selected in the list + HandleText(); + return NS_OK; + } + RowIndexToSearch(index, &searchIndex, &rowIndex); NS_ENSURE_TRUE(searchIndex >= 0 && rowIndex >= 0, NS_ERROR_FAILURE);