ui: Fixed text color not correctly changed when annotation type changes

This commit is contained in:
Eberhard Graether
2017-09-03 22:18:20 +02:00
parent 9f2509e7de
commit 602ebbfe46
4 changed files with 23 additions and 62 deletions
+4 -7
View File
@@ -163,7 +163,7 @@ void QtHighlighter::highlightDocument()
highlightMultiLineComments(&m_ranges);
}
void QtHighlighter::highlightRange(int startLine, int endLine, std::vector<std::pair<int, int>> ranges)
void QtHighlighter::highlightRange(int startLine, int endLine)
{
if (m_language == LANGUAGE_UNKNOWN)
{
@@ -190,13 +190,10 @@ void QtHighlighter::highlightRange(int startLine, int endLine, std::vector<std::
return;
}
QTextDocument* doc = document();
QTextBlock start = doc->findBlockByLineNumber(startLine);
QTextBlock end = doc->findBlockByLineNumber(endLine + 1);
ranges.insert(ranges.end(), m_ranges.begin(), m_ranges.end());
int index = startLine;
for (QTextBlock it = start; it != end; it = it.next())
{
@@ -204,7 +201,7 @@ void QtHighlighter::highlightRange(int startLine, int endLine, std::vector<std::
{
foreach (const HighlightingRule &rule, m_highlightingRules)
{
formatBlock(it, rule, &ranges, false);
formatBlock(it, rule, &m_ranges, false);
}
}
index++;
@@ -215,7 +212,7 @@ void QtHighlighter::highlightRange(int startLine, int endLine, std::vector<std::
{
if (!m_highlightedLines[index])
{
formatBlock(it, s_commentRule, &ranges, false);
formatBlock(it, s_commentRule, &m_ranges, false);
}
index++;
}
@@ -327,7 +324,7 @@ void QtHighlighter::formatBlock(
{
int length = expression.matchedLength();
if (!isInRange(pos + index, *ranges))
if (!isInRange(pos + index, *ranges) && !isInRange(pos + index + length, *ranges))
{
applyFormat(pos + index, pos + index + length, rule.format);
}
+1 -1
View File
@@ -16,7 +16,7 @@ public:
QtHighlighter(QTextDocument *parent, LanguageType language);
void highlightDocument();
void highlightRange(int startLine, int endLine, std::vector<std::pair<int, int>> ranges);
void highlightRange(int startLine, int endLine);
void rehighlightLines(const std::vector<int>& lines);