diff --git a/editor/base/nsEditor.cpp b/editor/base/nsEditor.cpp index d7dc587123b8..79a3d3299a8a 100644 --- a/editor/base/nsEditor.cpp +++ b/editor/base/nsEditor.cpp @@ -1481,7 +1481,20 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert) } else if (NS_ERROR_EDITOR_NO_TEXTNODE==result) { - result = Do(aggTxn); + + // only execute the aggTxn if we actually populated it with at least one sub-txn + PRInt32 count=0; + aggTxn->GetCount(&count); + if (0!=count) + { + result = Do(aggTxn); + } + else + { + result = NS_OK; + } + + // create the text node if (NS_SUCCEEDED(result)) { nsCOMPtr selection; diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index d7dc587123b8..79a3d3299a8a 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -1481,7 +1481,20 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert) } else if (NS_ERROR_EDITOR_NO_TEXTNODE==result) { - result = Do(aggTxn); + + // only execute the aggTxn if we actually populated it with at least one sub-txn + PRInt32 count=0; + aggTxn->GetCount(&count); + if (0!=count) + { + result = Do(aggTxn); + } + else + { + result = NS_OK; + } + + // create the text node if (NS_SUCCEEDED(result)) { nsCOMPtr selection;