diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index ab04d11f7ff93dafcadb5f4f95b39f39ed0916b9..fc3ee7d4e0d0d9206015dec879a1b0374e1fce59 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1080,7 +1080,7 @@ IEditor *EditorManager::createEditor(const QString &editorId,
             mimeType = m_d->m_core->mimeDatabase()->findByType(QLatin1String("text/plain"));
         }
         // open text files > 48 MB in binary editor
-        if (fileInfo.size() >  qint64(3) << 24 && mimeType.type().startsWith(QLatin1String("text")))
+        if (fileInfo.size() >  maxTextFileSize() && mimeType.type().startsWith(QLatin1String("text")))
             mimeType = m_d->m_core->mimeDatabase()->findByType(QLatin1String("application/octet-stream"));
         factories = editorFactories(mimeType, true);
     } else {
@@ -2013,5 +2013,10 @@ void EditorManager::gotoOtherSplit()
         }
     }
 }
+
+qint64 EditorManager::maxTextFileSize()
+{
+    return (qint64(3) << 24);
+}
 //===================EditorClosingCoreListener======================
 
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index e488f040ea0dfcfd242fcd7560d49252b343fdb1..541c5d335566975bdef14a811dcca795558e8539 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -199,6 +199,8 @@ public:
                                              QWidget *parent,
                                              bool displaySaveAsButton = false);
 
+    static qint64 maxTextFileSize();
+
 signals:
     void currentEditorChanged(Core::IEditor *editor);
     void editorCreated(Core::IEditor *editor, const QString &fileName);
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index e82160232b36726268d8c2773bea1d6c7a04b4ea..3283b7b77d77a6dfd33a17a90347134046e598bd 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -573,8 +573,19 @@ void BaseTextEditor::triggerQuickFix()
     emit requestQuickFix(editableInterface());
 }
 
+QString BaseTextEditor::msgTextTooLarge(quint64 size)
+{
+    return tr("The text is too large to be displayed (%1 MB).").
+           arg(size >> 20);
+}
+
 bool BaseTextEditor::createNew(const QString &contents)
 {
+    if (contents.size() > Core::EditorManager::maxTextFileSize()) {
+        setPlainText(msgTextTooLarge(contents.size()));
+        document()->setModified(false);
+        return false;
+    }
     setPlainText(contents);
     document()->setModified(false);
     return true;
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index afcc2548d041aee9c98a91d7497f9a9e38440540..8a0cb0499caec17ac7345e2dc09fb85a05970c04 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -294,6 +294,8 @@ protected:
     bool canInsertFromMimeData(const QMimeData *source) const;
     void insertFromMimeData(const QMimeData *source);
 
+    static QString msgTextTooLarge(quint64 size);
+
 private:
     void maybeSelectLine();
 
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 5186570852891ee9cf1ae9e30f1f1521bf9e7fed..af184590093bac4fbd8448eb7656a75e46d62d10 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -627,7 +627,11 @@ void VCSBaseEditor::jumpToChangeFromDiff(QTextCursor cursor)
 
 void VCSBaseEditor::setPlainTextData(const QByteArray &data)
 {
-    setPlainText(codec()->toUnicode(data));
+    if (data.size() > Core::EditorManager::maxTextFileSize()) {
+        setPlainText(msgTextTooLarge(data.size()));
+    } else {
+        setPlainText(codec()->toUnicode(data));
+    }
 }
 
 void VCSBaseEditor::setFontSettings(const TextEditor::FontSettings &fs)