diff --git a/editors/sc-ide/widgets/code_editor/highlighter.cpp b/editors/sc-ide/widgets/code_editor/highlighter.cpp index e9a330ce817..997d00fc3b2 100644 --- a/editors/sc-ide/widgets/code_editor/highlighter.cpp +++ b/editors/sc-ide/widgets/code_editor/highlighter.cpp @@ -68,6 +68,8 @@ SyntaxHighlighter::SyntaxHighlighter(QTextDocument* parent): QSyntaxHighlighter( mGlobals = SyntaxHighlighterGlobals::instance(); connect(mGlobals, SIGNAL(syntaxFormatsChanged()), this, SLOT(rehighlight())); + + connect(Main::scProcess(), &ScProcess::introspectionChanged, this, &SyntaxHighlighter::rehighlight); } void SyntaxHighlighter::highlightBlockInCode(ScLexer& lexer) { @@ -88,6 +90,7 @@ void SyntaxHighlighter::highlightBlockInCode(ScLexer& lexer) { case Token::Class: { auto className = QString(lexer.text().begin() + tokenPosition, tokenLength); + auto* classInstance = Main::scProcess()->introspection().findClass(className); if (classInstance != nullptr) @@ -208,6 +211,10 @@ void SyntaxHighlighter::highlightBlockInComment(ScLexer& lexer) { } void SyntaxHighlighter::highlightBlock(const QString& text) { + // if we don't have introspection yet don't format anything + if (!Main::scProcess()->introspection().introspectionAvailable()) + return; + TextBlockData* blockData = static_cast(currentBlockUserData()); if (!blockData) { blockData = new TextBlockData; diff --git a/editors/sc-ide/widgets/code_editor/highlighter.hpp b/editors/sc-ide/widgets/code_editor/highlighter.hpp index 33e5fdab3a8..0fae956c6f0 100644 --- a/editors/sc-ide/widgets/code_editor/highlighter.hpp +++ b/editors/sc-ide/widgets/code_editor/highlighter.hpp @@ -89,7 +89,7 @@ class SyntaxHighlighter : public QSyntaxHighlighter { SyntaxHighlighter(QTextDocument* parent = 0); private: - void highlightBlock(const QString& text); + void highlightBlock(const QString& text) override; void highlightBlockInCode(ScLexer& lexer); void highlightBlockInString(ScLexer& lexer); void highlightBlockInSymbol(ScLexer& lexer);