diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index b221daf9365283c724366b9551b2b0c5419ff39c..43c6b558bc920e7d6cd7199a7fac6e5eb2fc3881 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -174,6 +174,7 @@ void LLNotificationChiclet::onMenuItemClicked(const LLSD& user_data)
 	if("close all" == action)
 	{
 		LLNotificationWellWindow::getInstance()->closeAll();
+		LLIMWellWindow::getInstance()->closeAll();
 	}
 }
 
diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index 1b98b94b71d0929f71d43ee995d1c64fab90a6be..d86e1b3fd7a52a4bbe913473e2c1be07dc8d01fe 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -482,11 +482,14 @@ void LLFloaterIMNearbyChat::onChatBoxKeystroke()
 		if (LLGestureMgr::instance().matchPrefix(utf8_trigger, &utf8_out_str))
 		{
 			std::string rest_of_match = utf8_out_str.substr(utf8_trigger.size());
-			mInputEditor->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part
+			if (!rest_of_match.empty())
+			{
+				mInputEditor->setText(utf8_trigger + rest_of_match); // keep original capitalization for user-entered part
 
-			// Select to end of line, starting from the character
-			// after the last one the user typed.
-			mInputEditor->selectNext(rest_of_match, false);
+				// Select to end of line, starting from the character
+				// after the last one the user typed.
+				mInputEditor->selectNext(rest_of_match, false);
+			}
 		}
 		else if (matchChatTypeTrigger(utf8_trigger, &utf8_out_str))
 		{