diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp
index b95e8e521dcb5849910b13118e2720d329cb4ad6..0c23d0ade8a770f9c5ddd2906d69fe17b47b81fd 100644
--- a/src/plugins/texteditor/refactoringchanges.cpp
+++ b/src/plugins/texteditor/refactoringchanges.cpp
@@ -393,7 +393,7 @@ void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const
         QTextCursor selection(p.first.document());
         selection.setPosition(p.first.position());
         selection.setPosition(p.second.position(), QTextCursor::KeepAnchor);
-        ((*m_data).*(mf))(selection, m_fileName, m_editor->baseTextDocument());
+        ((*m_data).*(mf))(selection, m_fileName, m_editor ? m_editor->baseTextDocument() : 0);
     }
 }