diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 7b08961bb969d6672a66896d575dfc87cd98c61e..1dc3f8df2fca84bc57536f4c1fef4d772997c9e5 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -532,12 +532,20 @@ ITextMarkable *BaseTextEditor::markableInterface() const
     return baseTextDocument()->documentMarker();
 }
 
+void BaseTextEditor::maybeEmitTextChangedBecauseOfUndo()
+{
+    if (document()->isRedoAvailable())
+        emit d->m_editable->contentsChangedBecauseOfUndo();
+}
+
 ITextEditable *BaseTextEditor::editableInterface() const
 {
     if (!d->m_editable) {
         d->m_editable = const_cast<BaseTextEditor*>(this)->createEditableInterface();
         connect(this, SIGNAL(textChanged()),
                 d->m_editable, SIGNAL(contentsChanged()));
+        connect(this, SIGNAL(textChanged()),
+                this, SLOT(maybeEmitTextChangedBecauseOfUndo()));
         connect(this, SIGNAL(changed()),
                 d->m_editable, SIGNAL(changed()));
     }
@@ -696,15 +704,17 @@ void BaseTextEditor::editorContentsChange(int position, int charsRemoved, int ch
     if (d->m_animator)
         d->m_animator->finish();
 
+
     d->m_contentsChanged = true;
+    QTextDocument *doc = document();
 
     // Keep the line numbers and the block information for the text marks updated
     if (charsRemoved != 0) {
         d->updateMarksLineNumber();
         d->updateMarksBlock(document()->findBlock(position));
     } else {
-        const QTextBlock posBlock = document()->findBlock(position);
-        const QTextBlock nextBlock = document()->findBlock(position + charsAdded);
+        const QTextBlock posBlock = doc->findBlock(position);
+        const QTextBlock nextBlock = doc->findBlock(position + charsAdded);
         if (posBlock != nextBlock) {
             d->updateMarksLineNumber();
             d->updateMarksBlock(posBlock);
@@ -713,6 +723,9 @@ void BaseTextEditor::editorContentsChange(int position, int charsRemoved, int ch
             d->updateMarksBlock(posBlock);
         }
     }
+
+    if (doc->isRedoAvailable())
+        emit d->m_editable->contentsChangedBecauseOfUndo();
 }
 
 
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index 1f99155078b2ed7e890db9925c85449c888f4aa6..033085850e2c3273d8eec78f8b561606c6eb90d8 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -459,6 +459,7 @@ private slots:
     void highlightSearchResults(const QString &txt, Find::IFindSupport::FindFlags findFlags);
     void setFindScope(const QTextCursor &);
     void currentEditorChanged(Core::IEditor *editor);
+    void maybeEmitTextChangedBecauseOfUndo();
 
 private:
     Internal::BaseTextEditorPrivate *d;
diff --git a/src/plugins/texteditor/completionwidget.cpp b/src/plugins/texteditor/completionwidget.cpp
index 0ea4db801f96ec6427236fc0569d937db078cdbf..b102793b6de361564c8584505d2452c52dad9e4e 100644
--- a/src/plugins/texteditor/completionwidget.cpp
+++ b/src/plugins/texteditor/completionwidget.cpp
@@ -134,6 +134,8 @@ CompletionWidget::CompletionWidget(CompletionSupport *support, ITextEditable *ed
             this, SIGNAL(completionListClosed()));
     connect(m_completionListView, SIGNAL(activated(QModelIndex)),
             SLOT(closeList(QModelIndex)));
+    connect(editor, SIGNAL(contentsChangedBecauseOfUndo()),
+            this, SLOT(closeList()));
 }
 
 CompletionWidget::~CompletionWidget()
diff --git a/src/plugins/texteditor/itexteditor.h b/src/plugins/texteditor/itexteditor.h
index c474b92e72f2af7f369c7dd07669ddaafccbc2b2..3dbb3e264087c2b8bad829a84f3e6ea17f87cb6d 100644
--- a/src/plugins/texteditor/itexteditor.h
+++ b/src/plugins/texteditor/itexteditor.h
@@ -124,6 +124,7 @@ public:
 
 signals:
     void contentsChanged();
+    void contentsChangedBecauseOfUndo();
     void markRequested(TextEditor::ITextEditor *editor, int line);
     void markContextMenuRequested(TextEditor::ITextEditor *editor, int line, QMenu *menu);
     void tooltipRequested(TextEditor::ITextEditor *editor, const QPoint &globalPos, int position);