Commit bbf284bb authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

Only highlight the filename of an include as link

Previously the whole line turned into a link. I think it looks a bit
nicer now.
parent 6be3455a
......@@ -602,22 +602,6 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
if (!doc)
return link;
// Handle include directives
const unsigned lineno = cursor.blockNumber() + 1;
foreach (const Document::Include &incl, doc->includes()) {
if (incl.line() == lineno && incl.resolved()) {
link.fileName = incl.fileName();
link.pos = cursor.block().position();
link.length = cursor.block().length();
return link;
}
}
// Find the last symbol up to the cursor position
Symbol *lastSymbol = doc->findSymbolAt(line, column);
if (!lastSymbol)
return link;
QTextCursor tc = cursor;
static TokenUnderCursor tokenUnderCursor;
......@@ -625,9 +609,27 @@ CPPEditor::Link CPPEditor::findLinkAt(const QTextCursor &cursor,
QTextBlock block;
const SimpleToken tk = tokenUnderCursor(tc, &block);
// Handle include directives
if (tk.is(T_STRING_LITERAL) || tk.is(T_ANGLE_STRING_LITERAL)) {
const unsigned lineno = cursor.blockNumber() + 1;
foreach (const Document::Include &incl, doc->includes()) {
if (incl.line() == lineno && incl.resolved()) {
link.fileName = incl.fileName();
link.pos = cursor.block().position() + tk.position() + 1;
link.length = tk.length() - 2;
return link;
}
}
}
if (tk.isNot(T_IDENTIFIER))
return link;
// Find the last symbol up to the cursor position
Symbol *lastSymbol = doc->findSymbolAt(line, column);
if (!lastSymbol)
return link;
const int nameStart = tk.position();
const int nameLength = tk.length();
const int endOfName = nameStart + nameLength;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment