From 075fcde97220de84648a307cc7b6defe7d6f5dd0 Mon Sep 17 00:00:00 2001 From: Diego Iastrubni Date: Thu, 24 Oct 2024 18:48:44 +0300 Subject: [PATCH] TextEditorPlugin: fix selection of themes - #5 A regression in a235b3d6ca56bc768dfa613fc0b30c3eeab99298 which caused that when you choose themes - the synyax highlighter was borked. --- src/plugins/texteditor/texteditor_plg.cpp | 6 +++++- src/widgets/qmdieditor.h | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/texteditor/texteditor_plg.cpp b/src/plugins/texteditor/texteditor_plg.cpp index 8add2bd..d2e8df8 100644 --- a/src/plugins/texteditor/texteditor_plg.cpp +++ b/src/plugins/texteditor/texteditor_plg.cpp @@ -189,7 +189,6 @@ void TextEditorPlugin::on_client_merged(qmdiHost *) { p->setDataModel(model); p->show(); - auto langInfo = ::Qutepart::chooseLanguage({}, {}, editor->mdiClientFileName()); connect(p, &CommandPalette::didHide, this, [this, p, editor]() { if (!newThemeSelected) { editor->setEditorTheme(this->theme); @@ -329,6 +328,11 @@ bool TextEditorPlugin::openFile(const QString fileName, int x, int y, int zoom) f.setPointSize(zoom); editor->setFont(f); } + + auto langInfo = ::Qutepart::chooseLanguage({}, {}, fileName); + if (langInfo.isValid()) { + editor->setEditorHighlighter(langInfo.id, theme); + } applySettings(editor); auto loaded = editor->loadFile(fileName); mdiServer->addClient(editor); diff --git a/src/widgets/qmdieditor.h b/src/widgets/qmdieditor.h index 9aec8e5..a7ce6ba 100644 --- a/src/widgets/qmdieditor.h +++ b/src/widgets/qmdieditor.h @@ -59,9 +59,12 @@ class qmdiEditor : public QWidget, public qmdiClient { inline const Qutepart::Theme *getEditorTheme() { return textEditor->getTheme(); } inline void setEditorTheme(const Qutepart::Theme *theme) { textEditor->setTheme(theme); } inline void setEditorHighlighter(QString id, const Qutepart::Theme *theme) { - if (this->syntaxLangID == id) { - return; - } + /* + TODO: themes and synyax are merged. When we de-couple them this will get restoredr + if (this->syntaxLangID == id) { + return; + } + */ this->syntaxLangID = id; textEditor->setHighlighter(id, theme); }