aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2020-11-02 11:03:29 +0100
committerDavid Schulz <david.schulz@qt.io>2020-11-17 11:32:42 +0000
commit5da4c61f6c7007ca9d6e56a779fbb24ea82b1f54 (patch)
tree43485fd7a2322fe6cebd9e573064249856bd2ff5
parenteb4d230e3818bef7290fb12911de1f0d3a98d565 (diff)
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>
-rw-r--r--src/plugins/debugger/sourceutils.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/debugger/sourceutils.cpp b/src/plugins/debugger/sourceutils.cpp
index a492bb8308..a76317258c 100644
--- a/src/plugins/debugger/sourceutils.cpp
+++ b/src/plugins/debugger/sourceutils.cpp
@@ -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 == '_')