Debugger: Fix tooltip expression collector

Only use the selected text from the text cursor if the requested
position is inside the selection.

Task-number: QTCREATORBUG-24180
Change-Id: I1d9b07fec2f89c125fa6568aa76130f252e146a4
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2020-11-02 11:03:29 +01:00
parent eb4d230e38
commit 5da4c61f6c

View File

@@ -259,8 +259,10 @@ QString cppExpressionAt(TextEditorWidget *editorWidget, int pos,
const Snapshot snapshot = CppModelManager::instance()->snapshot();
const Document::Ptr document = snapshot.document(fileName);
QTextCursor tc = editorWidget->textCursor();
QString expr = tc.selectedText();
if (expr.isEmpty()) {
QString expr;
if (tc.hasSelection() && pos >= tc.selectionStart() && pos <= tc.selectionEnd()) {
expr = tc.selectedText();
} else {
tc.setPosition(pos);
const QChar ch = editorWidget->characterAt(pos);
if (ch.isLetterOrNumber() || ch == '_')