forked from qt-creator/qt-creator
TextEditor: Use synchronous highlighter by default
Change-Id: I796800972668d4cad9dd12aa4fcc9395febcce0f Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -914,19 +914,23 @@ bool TextDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type
|
|||||||
void TextDocument::resetSyntaxHighlighter(const std::function<SyntaxHighlighter *()> &creator,
|
void TextDocument::resetSyntaxHighlighter(const std::function<SyntaxHighlighter *()> &creator,
|
||||||
bool threaded)
|
bool threaded)
|
||||||
{
|
{
|
||||||
if (d->m_highlighterRunner)
|
delete d->m_highlighterRunner;
|
||||||
delete d->m_highlighterRunner;
|
|
||||||
|
|
||||||
static const bool envValue
|
static const std::optional<bool> envValue = []() -> std::optional<bool> {
|
||||||
= qtcEnvironmentVariable("QTC_USE_THREADED_HIGHLIGHTER", "TRUE").toUpper()
|
const QString key("QTC_USE_THREADED_HIGHLIGHTER");
|
||||||
== QLatin1String("TRUE");
|
if (qtcEnvironmentVariableIsSet(key)) {
|
||||||
|
const QString value = qtcEnvironmentVariable(key).toUpper();
|
||||||
|
return value != "FALSE" && value != "0";
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}();
|
||||||
|
|
||||||
SyntaxHighlighter *highlighter = creator();
|
SyntaxHighlighter *highlighter = creator();
|
||||||
highlighter->setFontSettings(TextEditorSettings::fontSettings());
|
highlighter->setFontSettings(TextEditorSettings::fontSettings());
|
||||||
highlighter->setMimeType(mimeType());
|
highlighter->setMimeType(mimeType());
|
||||||
d->m_highlighterRunner = new SyntaxHighlighterRunner(highlighter,
|
d->m_highlighterRunner = new SyntaxHighlighterRunner(highlighter,
|
||||||
document(),
|
document(),
|
||||||
threaded && envValue);
|
envValue.value_or(threaded));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextDocument::cleanWhitespace(const QTextCursor &cursor)
|
void TextDocument::cleanWhitespace(const QTextCursor &cursor)
|
||||||
|
@@ -127,7 +127,7 @@ public:
|
|||||||
QTextDocument *document() const;
|
QTextDocument *document() const;
|
||||||
|
|
||||||
using SyntaxHighLighterCreator = std::function<SyntaxHighlighter *()>;
|
using SyntaxHighLighterCreator = std::function<SyntaxHighlighter *()>;
|
||||||
void resetSyntaxHighlighter(const SyntaxHighLighterCreator &creator, bool threaded = true);
|
void resetSyntaxHighlighter(const SyntaxHighLighterCreator &creator, bool threaded = false);
|
||||||
SyntaxHighlighterRunner *syntaxHighlighterRunner() const;
|
SyntaxHighlighterRunner *syntaxHighlighterRunner() const;
|
||||||
|
|
||||||
bool reload(QString *errorString, QTextCodec *codec);
|
bool reload(QString *errorString, QTextCodec *codec);
|
||||||
|
Reference in New Issue
Block a user