diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 7c5b5991384..df0e64a956d 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -228,6 +228,7 @@ public: bool m_fileIsReadOnly; bool m_hasDecodingError; + bool m_hasHighlightWarning; QByteArray m_decodingErrorSample; static const int kChunkSize; @@ -245,6 +246,7 @@ BaseTextDocumentPrivate::BaseTextDocumentPrivate(BaseTextDocument *q) : m_fileHasUtf8Bom(false), m_fileIsReadOnly(false), m_hasDecodingError(false), + m_hasHighlightWarning(false), m_autoSaveRevision(-1) { } @@ -716,6 +718,16 @@ void BaseTextDocument::documentClosing() } } +bool BaseTextDocument::hasHighlightWarning() const +{ + return d->m_hasHighlightWarning; +} + +void BaseTextDocument::setHighlightWarning(bool has) +{ + d->m_hasHighlightWarning = has; +} + } // namespace TextEditor #include "basetextdocument.moc" diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index 481baae76cc..22d6e92fffe 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -103,6 +103,9 @@ public: bool reload(QString *errorString, QTextCodec *codec); void cleanWhitespace(const QTextCursor &cursor); + bool hasHighlightWarning() const; + void setHighlightWarning(bool has); + signals: void titleChanged(QString title); diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index accf655425f..9ee3160bd0c 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -32,6 +32,7 @@ #include "plaintexteditor.h" #include "plaintexteditorfactory.h" +#include "basetextdocument.h" #include "texteditorconstants.h" #include "texteditorplugin.h" #include "texteditoractionhandler.h" @@ -94,20 +95,29 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor) { PlainTextEditor *editorEditable = qobject_cast(editor); if (editorEditable) { + BaseTextDocument *file = qobject_cast(editor->file()); + if (!file) + return; PlainTextEditorWidget *textEditor = static_cast(editorEditable->editorWidget()); if (textEditor->isMissingSyntaxDefinition() && !textEditor->ignoreMissingSyntaxDefinition() && TextEditorSettings::instance()->highlighterSettings().alertWhenNoDefinition()) { + if (file->hasHighlightWarning()) + return; Core::InfoBarEntry info(Constants::INFO_SYNTAX_DEFINITION, tr("A highlight definition was not found for this file. " "Would you like to try to find one?")); info.setCustomButtonInfo(tr("Show highlighter options"), textEditor, SLOT(acceptMissingSyntaxDefinitionInfo())); info.setCancelButtonInfo(textEditor, SLOT(ignoreMissingSyntaxDefinitionInfo())); - editor->file()->infoBar()->addInfo(info); + file->infoBar()->addInfo(info); + file->setHighlightWarning(true); return; } - editor->file()->infoBar()->removeInfo(Constants::INFO_SYNTAX_DEFINITION); + if (!file->hasHighlightWarning()) + return; + file->infoBar()->removeInfo(Constants::INFO_SYNTAX_DEFINITION); + file->setHighlightWarning(false); } }