Simplified the code that looks for the identifier under the cursor.

This commit is contained in:
Roberto Raggi
2009-03-30 15:25:06 +02:00
parent 1949436635
commit 68d8d83093
3 changed files with 23 additions and 17 deletions

View File

@@ -42,7 +42,7 @@ TokenUnderCursor::TokenUnderCursor()
TokenUnderCursor::~TokenUnderCursor()
{ }
SimpleToken TokenUnderCursor::operator()(const QTextCursor &cursor) const
SimpleToken TokenUnderCursor::operator()(const QTextCursor &cursor, QTextBlock *b) const
{
SimpleLexer tokenize;
tokenize.setObjCEnabled(true);
@@ -54,8 +54,11 @@ SimpleToken TokenUnderCursor::operator()(const QTextCursor &cursor) const
QList<SimpleToken> tokens = tokenize(block.text(), previousBlockState(block));
for (int index = tokens.size() - 1; index != -1; --index) {
const SimpleToken &tk = tokens.at(index);
if (tk.position() < column)
if (tk.position() < column) {
if (b)
*b = block;
return tk;
}
}
return SimpleToken();