From 0c909fd2bd76944f42d95c047eb77992a0f7edf0 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Tue, 6 Dec 2016 14:27:54 +0100 Subject: [PATCH] logic: Fixed issues in tutorial * increased gap in code_tutorial_3.h so that next comment is not already visible * Fixed SearchMatch sorting to not loose matches with same name but different namespace --- .../projects/tutorial/src/code_tutorial_3.h | 15 +++++++------ src/lib/data/search/SearchMatch.cpp | 22 +++++++++++++------ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/bin/app/data/projects/tutorial/src/code_tutorial_3.h b/bin/app/data/projects/tutorial/src/code_tutorial_3.h index 2fb982de..968324d2 100644 --- a/bin/app/data/projects/tutorial/src/code_tutorial_3.h +++ b/bin/app/data/projects/tutorial/src/code_tutorial_3.h @@ -8,15 +8,15 @@ //------------------------------------------------------------------------------ // // 6 - SNIPPETS AND FILES -// It looks like this function is called in two different places inside the -// same file. When two different snippets are located in the same file they -// share a single file box. The line numbers to the left indicate where each of +// It looks like this function is called in two different places inside the +// same file. When two different snippets are located in the same file they +// share a single file box. The line numbers to the left indicate where each of // these snippets is located inside the file. // // 7 - MERGING SNIPPETS // The top line of each snippet shows the name of its own parent's scope. -// If you want to show the lines in between the two snippets below you can -// either expand the upper snippet's scope to show the whole file or you can +// If you want to show the lines in between the two snippets below you can +// either expand the upper snippet's scope to show the whole file or you can // tell the lower snippet to reveal its scope. // Try one of these approaches now. // @@ -27,6 +27,7 @@ void function_with_snippets() unrelated_but_very_important(); + //------------------------------------------------------------------------------ // // 8 - YOU FOUND THE HIDDEN COMMENT @@ -45,8 +46,8 @@ void function_with_snippets() // to the central hub. // // P.S. -// You can also click the file name above (i guess you need to scroll up a -// little bit) to activate the file's node in case you want to explore your +// You can also click the file name above (i guess you need to scroll up a +// little bit) to activate the file's node in case you want to explore your // include hierarchy. // //------------------------------------------------------------------------------ diff --git a/src/lib/data/search/SearchMatch.cpp b/src/lib/data/search/SearchMatch.cpp index 87a2c829..933ea343 100644 --- a/src/lib/data/search/SearchMatch.cpp +++ b/src/lib/data/search/SearchMatch.cpp @@ -117,31 +117,39 @@ bool SearchMatch::operator<(const SearchMatch& other) const return false; } + const std::string* str = &text; + const std::string* otherStr = &other.text; + if (*str == *otherStr) + { + str = &name; + otherStr = &other.name; + } + // text size - if (text.size() < other.text.size()) + if (str->size() < otherStr->size()) { return true; } - else if (text.size() > other.text.size()) + else if (str->size() > otherStr->size()) { return false; } // lower case - for (size_t i = 0; i < text.size(); i++) + for (size_t i = 0; i < str->size(); i++) { - if (tolower(text[i]) != tolower(other.text[i])) + if (tolower(str->at(i)) != tolower(otherStr->at(i))) { - return tolower(text[i]) < tolower(other.text[i]); + return tolower(str->at(i)) < tolower(otherStr->at(i)); } else { // alphabetical - if (text[i] < other.text[i]) + if (str->at(i) < otherStr->at(i)) { return true; } - else if (text[i] > other.text[i]) + else if (str->at(i) > otherStr->at(i)) { return false; }