Commit 2e17339b authored by hjk's avatar hjk

TextEditor: Reset mimetype after open() in all BaseTextEditors

This was already done in all major editors and should not harm
all others.

Change-Id: I7e19d285c4b85419a9a1f9afa961addecf682eaf
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 480efb02
......@@ -546,14 +546,6 @@ void CppEditorWidget::keyPressEvent(QKeyEvent *e)
TextEditor::BaseTextEditorWidget::keyPressEvent(e);
}
bool CppEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
if (!TextEditor::BaseTextEditor::open(errorString, fileName, realFileName))
return false;
textDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
return true;
}
void CppEditorWidget::applyFontSettings()
{
// This also makes the document apply font settings
......
......@@ -56,10 +56,6 @@ class CppEditor : public TextEditor::BaseTextEditor
public:
CppEditor();
bool open(QString *errorString,
const QString &fileName,
const QString &realFileName) QTC_OVERRIDE;
};
class CppEditorWidget : public TextEditor::BaseTextEditorWidget
......
......@@ -47,7 +47,6 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/id.h>
#include <coreplugin/mimedatabase.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
......@@ -326,26 +325,6 @@ IAssistInterface *GlslEditorWidget::createAssistInterface(
}
//
// GlslEditor
//
class GlslEditor : public TextEditor::BaseTextEditor
{
public:
GlslEditor()
{
}
bool open(QString *errorString, const QString &fileName, const QString &realFileName)
{
textDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
bool b = BaseTextEditor::open(errorString, fileName, realFileName);
return b;
}
};
//
// GlslEditorFactory
//
......@@ -362,7 +341,6 @@ GlslEditorFactory::GlslEditorFactory()
setDocumentCreator([]() { return new BaseTextDocument(Constants::C_GLSLEDITOR_ID); });
setEditorWidgetCreator([]() { return new GlslEditorWidget; });
setEditorCreator([]() { return new GlslEditor; });
setIndenterCreator([]() { return new GlslIndenter; });
setSyntaxHighlighterCreator([]() { return new GlslHighlighter; });
setCommentStyle(Utils::CommentDefinition::CppStyle);
......
......@@ -33,46 +33,17 @@
#include "tools/pythonindenter.h"
#include "tools/pythonhighlighter.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/indenter.h>
#include <texteditor/autocompleter.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
using namespace TextEditor;
namespace PythonEditor {
namespace Internal {
//
// PythonEditor
//
class PythonEditor : public BaseTextEditor
{
public:
PythonEditor()
{
}
bool open(QString *errorString, const QString &fileName, const QString &realFileName)
{
Core::MimeType mimeType = Core::MimeDatabase::findByFile(QFileInfo(fileName));
textDocument()->setMimeType(mimeType.type());
return BaseTextEditor::open(errorString, fileName, realFileName);
}
};
//
// PythonEditorWidget
//
......@@ -105,7 +76,6 @@ PythonEditorFactory::PythonEditorFactory()
setDocumentCreator([]() { return new BaseTextDocument(Constants::C_PYTHONEDITOR_ID); });
setEditorWidgetCreator([]() { return new PythonEditorWidget; });
setEditorCreator([]() { return new PythonEditor; });
setIndenterCreator([]() { return new PythonIndenter; });
setSyntaxHighlighterCreator([]() { return new PythonHighlighter; });
setCommentStyle(Utils::CommentDefinition::HashStyle);
......
......@@ -56,7 +56,6 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/id.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/modemanager.h>
#include <extensionsystem/pluginmanager.h>
......@@ -173,13 +172,6 @@ QModelIndex QmlJSEditorWidget::outlineModelIndex()
return m_outlineModelIndex;
}
bool QmlJSEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
bool b = BaseTextEditor::open(errorString, fileName, realFileName);
textDocument()->setMimeType(MimeDatabase::findByFile(QFileInfo(fileName)).type());
return b;
}
static void appendExtraSelectionsForMessages(
QList<QTextEdit::ExtraSelection> *selections,
const QList<DiagnosticMessage> &messages,
......
......@@ -145,7 +145,6 @@ class QmlJSEditor : public TextEditor::BaseTextEditor
public:
QmlJSEditor();
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
bool isDesignModePreferred() const;
};
......
......@@ -7024,7 +7024,10 @@ QString BaseTextEditorWidget::foldReplacementText(const QTextBlock &) const
bool BaseTextEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
return editorWidget()->open(errorString, fileName, realFileName);
if (!editorWidget()->open(errorString, fileName, realFileName))
return false;
textDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
return true;
}
QByteArray BaseTextEditor::saveState() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment