Skip to content

Commit

Permalink
TextEditorPlugin: fix selection of themes - #5
Browse files Browse the repository at this point in the history
A regression in a235b3d which caused
that when you choose themes - the synyax highlighter was borked.
  • Loading branch information
diegoiast committed Oct 24, 2024
1 parent 6d708eb commit 075fcde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/plugins/texteditor/texteditor_plg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions src/widgets/qmdieditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 075fcde

Please sign in to comment.