diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 1f890b625f5c1e666f7f9b6dc7e2bc16a1fa2eb0..0040be45c711cde660eb72359177e87e4571ac56 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1513,6 +1513,8 @@ void LLTextBase::getSegmentAndOffset( S32 startpos, segment_set_t::iterator* seg
 LLTextBase::segment_set_t::iterator LLTextBase::getEditableSegIterContaining(S32 index)
 {
 	segment_set_t::iterator it = getSegIterContaining(index);
+	segment_set_t::iterator orig_it = it;
+
 	if (it == mSegments.end()) return it;
 
 	if (!(*it)->canEdit() 
@@ -1520,13 +1522,18 @@ LLTextBase::segment_set_t::iterator LLTextBase::getEditableSegIterContaining(S32
 		&& it != mSegments.begin())
 	{
 		it--;
+		if ((*it)->canEdit())
+		{
+			return it;
+		}
 	}
-	return it;
+	return orig_it;
 }
 
 LLTextBase::segment_set_t::const_iterator LLTextBase::getEditableSegIterContaining(S32 index) const
 {
 	segment_set_t::const_iterator it = getSegIterContaining(index);
+	segment_set_t::const_iterator orig_it = it;
 	if (it == mSegments.end()) return it;
 
 	if (!(*it)->canEdit() 
@@ -1534,8 +1541,12 @@ LLTextBase::segment_set_t::const_iterator LLTextBase::getEditableSegIterContaini
 		&& it != mSegments.begin())
 	{
 		it--;
+		if ((*it)->canEdit())
+		{
+			return it;
+		}
 	}
-	return it;
+	return orig_it;
 }
 
 LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index)
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index f21fb37e182ecbe2feb5aa2828544081ec7f6306..f1fac5f69ce90483d03744e413ecc06cff25fa4f 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -612,6 +612,8 @@ class LLView
 
 	S32			mNextInsertionOrdinal;
 
+	bool		mInDraw;
+
 	static LLWindow* sWindow;	// All root views must know about their window.
 
 	typedef std::map<std::string, LLView*> default_widget_map_t;