Commit b25c3c74 authored by Simon Martens's avatar Simon Martens Committed by Ralf Habacker

Remove independent comments from list in CommentStore::getCommentsInRange()

The testcase used to fix this issue is located at test/import/cxx/comment-class.h.
parent e154151c
......@@ -242,9 +242,30 @@ public:
*/
Comment getCommentsInRange(int end, int start = 0)
{
Comment ret;
if (m_comments.empty())
return ret;
// The following lines will look ahead if there is a independent comment.
CommentSet::iterator it = m_comments.begin();
Comment ret;
int tempLine = (*it).line();
++it;
while (it != m_comments.end() && (*it).line() >= start && (*it).line() <= end) {
if(tempLine == ((*it).line() - 1)) {
tempLine++;
++it;
} else {
--it;
m_comments.erase(it); // The independent comment is deleted
break;
}
}
it = m_comments.begin(); // Redefines the beginning of the container
while (it != m_comments.end() && (*it).line() >= start && (*it).line() <= end) {
if (ret)
ret += *it;
......
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