forked from qt-creator/qt-creator
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:
@@ -259,8 +259,10 @@ QString cppExpressionAt(TextEditorWidget *editorWidget, int pos,
|
|||||||
const Snapshot snapshot = CppModelManager::instance()->snapshot();
|
const Snapshot snapshot = CppModelManager::instance()->snapshot();
|
||||||
const Document::Ptr document = snapshot.document(fileName);
|
const Document::Ptr document = snapshot.document(fileName);
|
||||||
QTextCursor tc = editorWidget->textCursor();
|
QTextCursor tc = editorWidget->textCursor();
|
||||||
QString expr = tc.selectedText();
|
QString expr;
|
||||||
if (expr.isEmpty()) {
|
if (tc.hasSelection() && pos >= tc.selectionStart() && pos <= tc.selectionEnd()) {
|
||||||
|
expr = tc.selectedText();
|
||||||
|
} else {
|
||||||
tc.setPosition(pos);
|
tc.setPosition(pos);
|
||||||
const QChar ch = editorWidget->characterAt(pos);
|
const QChar ch = editorWidget->characterAt(pos);
|
||||||
if (ch.isLetterOrNumber() || ch == '_')
|
if (ch.isLetterOrNumber() || ch == '_')
|
||||||
|
|||||||
Reference in New Issue
Block a user