Skip to content
Snippets Groups Projects
Commit 5b88093b authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS semantic highlighter: Abort when file changes.

Fixes the warning in incrementalApplyExtraAdditionalFormats being
triggered when the document is reduced in size while a highlight is
running.

Change-Id: I60e0c8772d511f52ee433d27cc77ba726030b354
Reviewed-on: http://codereview.qt-project.org/4661


Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent c36e017d
No related branches found
No related tags found
No related merge requests found
...@@ -1015,6 +1015,8 @@ void QmlJSTextEditorWidget::showTextMarker() ...@@ -1015,6 +1015,8 @@ void QmlJSTextEditorWidget::showTextMarker()
void QmlJSTextEditorWidget::updateUses() void QmlJSTextEditorWidget::updateUses()
{ {
if (m_semanticHighlighter->startRevision() != editorRevision())
m_semanticHighlighter->cancel();
m_updateUsesTimer->start(); m_updateUsesTimer->start();
} }
......
...@@ -386,6 +386,11 @@ void SemanticHighlighter::rerun(const ScopeChain &scopeChain) ...@@ -386,6 +386,11 @@ void SemanticHighlighter::rerun(const ScopeChain &scopeChain)
m_watcher.setFuture(f); m_watcher.setFuture(f);
} }
void SemanticHighlighter::cancel()
{
m_watcher.cancel();
}
void SemanticHighlighter::applyResults(int from, int to) void SemanticHighlighter::applyResults(int from, int to)
{ {
if (m_watcher.isCanceled()) if (m_watcher.isCanceled())
...@@ -432,3 +437,7 @@ void SemanticHighlighter::updateFontSettings(const TextEditor::FontSettings &fon ...@@ -432,3 +437,7 @@ void SemanticHighlighter::updateFontSettings(const TextEditor::FontSettings &fon
m_formats[LocalStateNameType] = fontSettings.toTextCharFormat(QLatin1String(TextEditor::Constants::C_QML_STATE_NAME)); m_formats[LocalStateNameType] = fontSettings.toTextCharFormat(QLatin1String(TextEditor::Constants::C_QML_STATE_NAME));
} }
int SemanticHighlighter::startRevision() const
{
return m_startRevision;
}
...@@ -77,6 +77,9 @@ public: ...@@ -77,6 +77,9 @@ public:
SemanticHighlighter(QmlJSTextEditorWidget *editor); SemanticHighlighter(QmlJSTextEditorWidget *editor);
void rerun(const QmlJS::ScopeChain &scopeChain); void rerun(const QmlJS::ScopeChain &scopeChain);
void cancel();
int startRevision() const;
void updateFontSettings(const TextEditor::FontSettings &fontSettings); void updateFontSettings(const TextEditor::FontSettings &fontSettings);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment