better lexer name handling
This commit is contained in:
@@ -10,32 +10,6 @@
|
||||
#include <ILexer.h>
|
||||
#include <Lexilla.h>
|
||||
|
||||
static QString lexerNameForDocumentLanguage(const QString &language)
|
||||
{
|
||||
if (language == QStringLiteral("C++") ||
|
||||
language == QStringLiteral("C") ||
|
||||
language == QStringLiteral("C/C++ Header")) {
|
||||
return QStringLiteral("cpp");
|
||||
}
|
||||
if (language == QStringLiteral("Python")) {
|
||||
return QStringLiteral("python");
|
||||
}
|
||||
if (language == QStringLiteral("HTML")) {
|
||||
return QStringLiteral("hypertext");
|
||||
}
|
||||
if (language == QStringLiteral("XML")) {
|
||||
return QStringLiteral("xml");
|
||||
}
|
||||
if (language == QStringLiteral("JSON")) {
|
||||
return QStringLiteral("json");
|
||||
}
|
||||
if (language == QStringLiteral("CSS")) {
|
||||
return QStringLiteral("css");
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
TabWidget::TabWidget(DocumentManager *documentManager, QWidget *parent)
|
||||
: QTabWidget(parent)
|
||||
, m_documentManager(documentManager)
|
||||
@@ -107,7 +81,7 @@ int TabWidget::openDocument(const QString &filePath)
|
||||
editor->setEditorFont(AppSettings::editorFont());
|
||||
editor->applyTheme(AppSettings::editorDarkTheme());
|
||||
|
||||
const QString lexerName = lexerNameForDocumentLanguage(m_documentManager->getDocumentLanguage(docId));
|
||||
const QString lexerName = m_documentManager->getDocumentLanguage(docId);
|
||||
if (lexerName.isEmpty()) {
|
||||
editor->setLexer(nullptr);
|
||||
} else {
|
||||
@@ -179,7 +153,7 @@ bool TabWidget::saveCurrentDocumentAs()
|
||||
|
||||
const bool saved = m_documentManager->saveDocumentAs(docId, fileName);
|
||||
if (saved) {
|
||||
const QString lexerName = lexerNameForDocumentLanguage(m_documentManager->getDocumentLanguage(docId));
|
||||
const QString lexerName = m_documentManager->getDocumentLanguage(docId);
|
||||
if (lexerName.isEmpty()) {
|
||||
editor->setLexer(nullptr);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user