forked from qt-creator/qt-creator
Debugger: More robust document access in cppExpressionAt
Change-Id: I53658225e001b0568c77f095d18e9452b792c5f9 Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -35,11 +35,12 @@
|
|||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
#include <cpptools/abstracteditorsupport.h>
|
#include <cpptools/abstracteditorsupport.h>
|
||||||
#include <cpptools/cppprojectfile.h>
|
#include <cpptools/cppprojectfile.h>
|
||||||
|
|
||||||
#include <cpptools/cppmodelmanagerinterface.h>
|
#include <cpptools/cppmodelmanagerinterface.h>
|
||||||
#include <cplusplus/ExpressionUnderCursor.h>
|
#include <cplusplus/ExpressionUnderCursor.h>
|
||||||
#include <cplusplus/Overview.h>
|
#include <cplusplus/Overview.h>
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -334,13 +335,14 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos,
|
|||||||
if (!plaintext)
|
if (!plaintext)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QString expr = plaintext->textCursor().selectedText();
|
QTextCursor tc = plaintext->textCursor();
|
||||||
|
QString expr = tc.selectedText();
|
||||||
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
|
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
|
||||||
if (expr.isEmpty() && modelManager) {
|
if (expr.isEmpty() && modelManager) {
|
||||||
QTextCursor tc(plaintext->document());
|
QTextDocument *doc = plaintext->document();
|
||||||
|
QTC_ASSERT(doc, return QString());
|
||||||
tc.setPosition(pos);
|
tc.setPosition(pos);
|
||||||
|
const QChar ch = doc->characterAt(pos);
|
||||||
const QChar ch = editor->textDocument()->characterAt(pos);
|
|
||||||
if (ch.isLetterOrNumber() || ch == QLatin1Char('_'))
|
if (ch.isLetterOrNumber() || ch == QLatin1Char('_'))
|
||||||
tc.movePosition(QTextCursor::EndOfWord);
|
tc.movePosition(QTextCursor::EndOfWord);
|
||||||
|
|
||||||
@@ -350,7 +352,6 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos,
|
|||||||
*column = tc.positionInBlock();
|
*column = tc.positionInBlock();
|
||||||
*line = tc.blockNumber();
|
*line = tc.blockNumber();
|
||||||
} else {
|
} else {
|
||||||
const QTextCursor tc = plaintext->textCursor();
|
|
||||||
*column = tc.positionInBlock();
|
*column = tc.positionInBlock();
|
||||||
*line = tc.blockNumber();
|
*line = tc.blockNumber();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user