logic: search bar duplicates
* When a location is clicked in the code that has more than one TokenLocations pointing to the same element, only one instance of the element is displayed in the search bar.
This commit is contained in:
@@ -881,7 +881,7 @@ std::vector<Id> Storage::getActiveTokenIdsForId(Id tokenId, Id* declarationId) c
|
|||||||
|
|
||||||
std::vector<Id> Storage::getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const
|
std::vector<Id> Storage::getNodeIdsForLocationIds(const std::vector<Id>& locationIds) const
|
||||||
{
|
{
|
||||||
std::vector<Id> nodeIds;
|
std::set<Id> nodeIds;
|
||||||
|
|
||||||
for (Id locationId : locationIds)
|
for (Id locationId : locationIds)
|
||||||
{
|
{
|
||||||
@@ -890,15 +890,15 @@ std::vector<Id> Storage::getNodeIdsForLocationIds(const std::vector<Id>& locatio
|
|||||||
StorageEdge edge = m_sqliteStorage.getEdgeById(elementId);
|
StorageEdge edge = m_sqliteStorage.getEdgeById(elementId);
|
||||||
if (edge.id != 0) // here we test if location is an edge.
|
if (edge.id != 0) // here we test if location is an edge.
|
||||||
{
|
{
|
||||||
nodeIds.push_back(edge.targetNodeId);
|
nodeIds.insert(edge.targetNodeId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nodeIds.push_back(elementId);
|
nodeIds.insert(elementId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeIds;
|
return utility::toVector(nodeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Id> Storage::getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const
|
std::vector<Id> Storage::getTokenIdsForMatches(const std::vector<SearchMatch>& matches) const
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ namespace utility
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
std::vector<T> toVector(const std::deque<T>& d);
|
std::vector<T> toVector(const std::deque<T>& d);
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::vector<T> toVector(const std::set<T>& d);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::vector<std::string> toStrings(const std::vector<T>& d);
|
std::vector<std::string> toStrings(const std::vector<T>& d);
|
||||||
|
|
||||||
@@ -81,6 +84,14 @@ std::vector<T> utility::toVector(const std::deque<T>& d)
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::vector<T> utility::toVector(const std::set<T>& d)
|
||||||
|
{
|
||||||
|
std::vector<T> v;
|
||||||
|
v.insert(v.begin(), d.begin(), d.end());
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::vector<std::string> utility::toStrings(const std::vector<T>& d)
|
std::vector<std::string> utility::toStrings(const std::vector<T>& d)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -419,7 +419,6 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
|
|
||||||
if (Qt::KeyboardModifier::ControlModifier && QApplication::keyboardModifiers())
|
if (Qt::KeyboardModifier::ControlModifier && QApplication::keyboardModifiers())
|
||||||
{
|
{
|
||||||
// std::pair<int, int> lineColumn = toLineColumn(this->cursorForPosition(event->pos()).position());
|
|
||||||
m_eventPosition = event->pos();
|
m_eventPosition = event->pos();
|
||||||
setIDECursorPosition();
|
setIDECursorPosition();
|
||||||
}
|
}
|
||||||
@@ -429,7 +428,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
std::vector<const Annotation*> annotations = getAnnotationsForPosition(cursor.position());
|
std::vector<const Annotation*> annotations = getAnnotationsForPosition(cursor.position());
|
||||||
|
|
||||||
std::vector<Id> locationIds;
|
std::vector<Id> locationIds;
|
||||||
std::vector<Id> tokenIds;
|
std::set<Id> tokenIds;
|
||||||
|
|
||||||
bool allActive = true;
|
bool allActive = true;
|
||||||
for (const Annotation* annotation : annotations)
|
for (const Annotation* annotation : annotations)
|
||||||
@@ -445,7 +444,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
}
|
}
|
||||||
if (annotation->tokenId > 0)
|
if (annotation->tokenId > 0)
|
||||||
{
|
{
|
||||||
tokenIds.push_back(annotation->tokenId);
|
tokenIds.insert(annotation->tokenId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,9 +457,9 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
{
|
{
|
||||||
MessageActivateTokenLocations(locationIds).dispatch();
|
MessageActivateTokenLocations(locationIds).dispatch();
|
||||||
}
|
}
|
||||||
else if (tokenIds.size())
|
else if (tokenIds.size()) // fallback for links in project description
|
||||||
{
|
{
|
||||||
MessageActivateTokenIds(tokenIds).dispatch();
|
MessageActivateTokenIds(utility::toVector(tokenIds)).dispatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user