Commit 3dec4855 authored by Andre Hartmann's avatar Andre Hartmann Committed by Erik Verbruggen
Browse files

Fix C++ Macro Usages when Definition contains Newline.



Now truncates the displayed line at the first Newline character after
the Macro name.

Task-number: QTCREATORBUG-7113

Change-Id: Ifb13c01d10b97098b54ac4346a80f0dcff3a35f3
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@nokia.com>
parent 60db5736
......@@ -646,9 +646,14 @@ void CppFindReferences::findMacroUses(const Macro &macro)
{
// ### FIXME: Encoding?
const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1();
const QByteArray line = source.mid(macro.offset(), macro.length());
QByteArray line = source.mid(macro.offset(), macro.length());
const int macroNameOffset = line.indexOf(macro.name());
const int macroNameLength = macro.name().length();
const int possibleNewLine = line.indexOf('\n', macroNameOffset + macroNameLength);
if (possibleNewLine != -1)
line.truncate(possibleNewLine); // truncate line at first '\n' after macro name
search->addResult(macro.fileName(), macro.line(), line,
line.indexOf(macro.name()), macro.name().length());
macroNameOffset, macroNameLength);
}
QFuture<Usage> result;
......
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