diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 1e69f730aaf9e9091584614b8e6d0e43ed30feb6..4dd62e22e09edf12a82b52ce56444d07b30dd05b 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -908,7 +908,6 @@ void CPPEditor::renameSymbolUnderCursor() QTextCursor c = textCursor(); m_currentRenameSelection = -1; - m_renameSelections = extraSelections(CodeSemanticsSelection); for (int i = 0; i < m_renameSelections.size(); ++i) { QTextEdit::ExtraSelection s = m_renameSelections.at(i); if (c.position() >= s.cursor.anchor() @@ -980,10 +979,9 @@ void CPPEditor::highlightUses(const QList<SemanticInfo::Use> &uses, QList<QTextEdit::ExtraSelection> *selections) { bool isUnused = false; - if (uses.size() == 1) { + + if (uses.size() == 1) isUnused = true; - return; // ### - } foreach (const SemanticInfo::Use &use, uses) { QTextEdit::ExtraSelection sel; @@ -1882,7 +1880,6 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs) // only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link m_occurrencesFormat.clearForeground(); - m_occurrencesUnusedFormat.clearForeground(); m_occurrenceRenameFormat.clearForeground(); } @@ -1944,7 +1941,9 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo) int line = 0, column = 0; convertPosition(position(), &line, &column); - QList<QTextEdit::ExtraSelection> selections; + QList<QTextEdit::ExtraSelection> allSelections; + + m_renameSelections.clear(); SemanticInfo::LocalUseIterator it(semanticInfo.localUses); while (it.hasNext()) { @@ -1961,11 +1960,18 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo) } } - if (uses.size() == 1 || good) + if (uses.size() == 1) { + // it's an unused declaration + highlightUses(uses, &allSelections); + } else if (good) { + QList<QTextEdit::ExtraSelection> selections; highlightUses(uses, &selections); + m_renameSelections += selections; + allSelections += selections; + } } - setExtraSelections(CodeSemanticsSelection, selections); + setExtraSelections(CodeSemanticsSelection, allSelections); } SemanticHighlighter::Source CPPEditor::currentSource()