-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow option to score code snippets above anything else #63
Comments
Poking around I couldn't see anything that would give us the ability to check the completion is backed by a snippet/macro. However, I implemented this by adding a bonus for exact matches: - (double) scoreItem: (id<DVTTextCompletionItem>) item
searchString: (NSString *) query
matchedName: (NSString *) matchedName
matchScore: (double) matchScore
matchedRanges: (NSArray *) rangesArray
priorityFactor: (double) priorityFactor
{
double invertedPriority = (10.0 / MAX(item.priority, 1.0));
priorityFactor = MAX(priorityFactor, 1.0);
NSRange range = [[rangesArray firstObject] rangeValue];
double prefixBonus = range.location ? 1.0 : 1.0 + (_maxPrefixBonus * range.length) / query.length;
double matchBonus = [query isEqualToString:matchedName] ? 10.0 : 1.0;
return matchBonus * pow(matchScore, _matchScorePower) * pow(priorityFactor, _priorityFactorPower) * pow(invertedPriority, _priorityPower) * prefixBonus;
} I'll see how I go with coding now and if it's a good fit or not. |
Actually you can, you just need to check But snippets have low Also, If it turns out this kind of bonus is really needed, it is also a good idea to try to keep the scoring function as continuous as possible, with the bonus increasing as the match approaches exact match, for example by adding a power to prefix bonus rather than introducing bonus just for exact match. |
+1 for this option |
It would be nice if it fuzzy autocomplete would score code snippets above anything else if the snippet's completion text is an exact match.
The text was updated successfully, but these errors were encountered: