Score leaf nodes in LIB_TREEs, not just symbols & footprints.
Fixes: lp:1783251 * https://bugs.launchpad.net/kicad/+bug/1783251
This commit is contained in:
parent
9175a48c90
commit
4e3c84e733
|
@ -267,10 +267,34 @@ void LIB_TREE_NODE_LIB::UpdateScore( EDA_COMBINED_MATCHER& aMatcher )
|
|||
{
|
||||
Score = 0;
|
||||
|
||||
for( auto& child: Children )
|
||||
// We need to score leaf nodes, which are usually (but not always) children.
|
||||
|
||||
if( Children.size() )
|
||||
{
|
||||
child->UpdateScore( aMatcher );
|
||||
Score = std::max( Score, child->Score );
|
||||
for( auto& child: Children )
|
||||
{
|
||||
child->UpdateScore( aMatcher );
|
||||
Score = std::max( Score, child->Score );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No children; we are a leaf.
|
||||
int found_pos = EDA_PATTERN_NOT_FOUND;
|
||||
int matchers_fired = 0;
|
||||
|
||||
if( aMatcher.GetPattern() == MatchName )
|
||||
{
|
||||
Score += 1000; // exact match. High score :)
|
||||
}
|
||||
else if( aMatcher.Find( MatchName, matchers_fired, found_pos ) )
|
||||
{
|
||||
// Substring match. The earlier in the string the better.
|
||||
Score += matchPosScore( found_pos, 20 ) + 20;
|
||||
}
|
||||
|
||||
// More matchers = better match
|
||||
Score += 2 * matchers_fired;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -369,10 +369,8 @@ void LIB_TREE_MODEL_ADAPTER::FindAndExpand( LIB_TREE_NODE& aNode,
|
|||
if( !(*aHighScore) || node->Score > (*aHighScore)->Score )
|
||||
(*aHighScore) = &*node;
|
||||
}
|
||||
else
|
||||
{
|
||||
FindAndExpand( *node, aFunc, aHighScore );
|
||||
}
|
||||
|
||||
FindAndExpand( *node, aFunc, aHighScore );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -384,7 +382,7 @@ LIB_TREE_NODE* LIB_TREE_MODEL_ADAPTER::ShowResults()
|
|||
FindAndExpand( m_tree,
|
||||
[]( LIB_TREE_NODE const* n )
|
||||
{
|
||||
return n->Type == LIB_TREE_NODE::TYPE::LIBID && n->Score > 1;
|
||||
return /*n->Type == LIB_TREE_NODE::TYPE::LIBID &&*/ n->Score > 1;
|
||||
},
|
||||
&highScore );
|
||||
|
||||
|
|
Loading…
Reference in New Issue