forked from qt-creator/qt-creator
CppEditor: Consider symbol occurrences in comments
... when renaming. For local renaming, we consider only function parameters. Task-number: QTCREATORBUG-12051 Change-Id: I7948d69f11b97663c9bd747ae6241a82dd9bdd82 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -848,7 +848,7 @@ void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *w
|
||||
q->cancelRequest(m_highlightRequests.take(widget));
|
||||
});
|
||||
request.setResponseCallback(
|
||||
[widget, this, uri, connection]
|
||||
[widget, this, uri, connection, adjustedCursor]
|
||||
(const DocumentHighlightsRequest::Response &response)
|
||||
{
|
||||
m_highlightRequests.remove(widget);
|
||||
@@ -874,6 +874,30 @@ void ClientPrivate::requestDocumentHighlightsNow(TextEditor::TextEditorWidget *w
|
||||
selection.cursor.setPosition(end, QTextCursor::KeepAnchor);
|
||||
selections << selection;
|
||||
}
|
||||
if (!selections.isEmpty()) {
|
||||
const QList<Text::Range> extraRanges = q->additionalDocumentHighlights(
|
||||
widget, adjustedCursor);
|
||||
for (const Text::Range &range : extraRanges) {
|
||||
QTextEdit::ExtraSelection selection{widget->textCursor(), format};
|
||||
const Text::Position &startPos = range.begin;
|
||||
const Text::Position &endPos = range.end;
|
||||
const int start = Text::positionInText(document, startPos.line,
|
||||
startPos.column + 1);
|
||||
const int end = Text::positionInText(document, endPos.line,
|
||||
endPos.column + 1);
|
||||
if (start < 0 || end < 0 || start >= end)
|
||||
continue;
|
||||
selection.cursor.setPosition(start);
|
||||
selection.cursor.setPosition(end, QTextCursor::KeepAnchor);
|
||||
static const auto cmp = [](const QTextEdit::ExtraSelection &s1,
|
||||
const QTextEdit::ExtraSelection &s2) {
|
||||
return s1.cursor.position() < s2.cursor.position();
|
||||
};
|
||||
const auto it = std::lower_bound(selections.begin(), selections.end(),
|
||||
selection, cmp);
|
||||
selections.insert(it, selection);
|
||||
}
|
||||
}
|
||||
widget->setExtraSelections(id, selections);
|
||||
});
|
||||
m_highlightRequests[widget] = request.id();
|
||||
|
||||
Reference in New Issue
Block a user