From 03b626c80cdafe2da29ba605689142e1048fe4e6 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Tue, 17 Aug 2010 14:50:08 +0200 Subject: [PATCH] Move the cursor at the character before the delimiter. --- src/plugins/cppeditor/cppeditor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index a33c23d6f7d..27b7d1a589b 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -1226,7 +1226,11 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor, if (! recognizedQtMethod) { const QTextBlock block = tc.block(); - const Token tk = SimpleLexer::tokenAt(block.text(), cursor.positionInBlock(), BackwardsScanner::previousBlockState(block), true); + int pos = cursor.positionInBlock(); + QChar ch = document()->characterAt(cursor.position()); + if (pos > 0 && ! (ch.isLetterOrNumber() || ch == QLatin1Char('_'))) + --pos; // positionInBlock points to a delimiter character. + const Token tk = SimpleLexer::tokenAt(block.text(), pos, BackwardsScanner::previousBlockState(block), true); beginOfToken = block.position() + tk.begin(); endOfToken = block.position() + tk.end();