From 998e4ae139cce549f8114eee24da0f439c24cae9 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Tue, 3 Apr 2012 20:04:39 +0200 Subject: [PATCH] Fix C++ Macro Usages definition line in Search Results. Add the complete line to the Search Results window, including '#', "define", macro and macro value and all possible white spaces between them. Also covers the case of line continuation in macro definitions from commit 3dec48557a2b9ff64237d2aa4077c65a62c6af42. Task-number: QTCREATORBUG-7217 Change-Id: I8b9d0c23d31ef76244833a9b9d67469c5c4a5635 Reviewed-by: Roberto Raggi --- src/plugins/cpptools/cppfindreferences.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 2182f7c8512..2c47a6b371e 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -646,14 +646,13 @@ void CppFindReferences::findMacroUses(const Macro ¯o) { // ### FIXME: Encoding? const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1(); - 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 + int lineBegin = source.lastIndexOf('\n', macro.offset()) + 1; + int lineEnd = source.indexOf('\n', macro.offset()); + if (lineEnd == -1) + lineEnd = source.length(); + const QByteArray line = source.mid(lineBegin, lineEnd - lineBegin); search->addResult(macro.fileName(), macro.line(), line, - macroNameOffset, macroNameLength); + line.indexOf(macro.name()), macro.name().length()); } QFuture result;