@@ -26,7 +26,7 @@ public static int CalculateMatchScore(string inputText, string matchText, out in
2626
2727 const int InvalidSocre = - 1 ; //无效分数
2828 const int InitSocreRewards = 1 ; //初始分数奖励
29- const int UpperMatchSocre = 5 ; //大写匹配分数
29+ const int SpecialMatchSocre = 5 ; //特殊匹配分数 - AaaBbb 中的 B; aaa_bbb 中 _ 后的 b
3030
3131 var currentCompletionScore = InvalidSocre ;
3232 charsMatchedCount = 0 ;
@@ -55,19 +55,21 @@ public static int CalculateMatchScore(string inputText, string matchText, out in
5555 }
5656 }
5757 return i == matchText . Length - 1
58- ? i * 1000 * UpperMatchSocre
59- : i * 100 * UpperMatchSocre ;
58+ ? i * 1000 * SpecialMatchSocre
59+ : i * 100 * SpecialMatchSocre ;
6060 }
6161
6262 //下方逻辑是从 CompletionSet 中 copy 后改的
6363
6464 var inputIndex = 0 ;
6565 var matchIndex = 0 ;
6666 var scoreRewards = InitSocreRewards ; //分数奖励
67+ var preOriginMatchChar = char . MinValue ; //上一个原始匹配字符
6768
6869 for ( ; inputIndex < inputLength ; inputIndex ++ )
6970 {
7071 var inputChar = char . ToLowerInvariant ( inputText [ inputIndex ] ) ;
72+ preOriginMatchChar = char . MinValue ;
7173
7274 for ( ; matchIndex < matchLength ; )
7375 {
@@ -87,22 +89,27 @@ public static int CalculateMatchScore(string inputText, string matchText, out in
8789 continue ;
8890 }
8991
90- if ( char . IsUpper ( originMatchChar ) ) //大写字母匹配
92+ if ( char . IsUpper ( originMatchChar ) ) //当前为大写字母匹配
9193 {
92- currentCompletionScore += UpperMatchSocre + scoreRewards ;
94+ if ( char . IsLower ( preOriginMatchChar )
95+ || char . IsPunctuation ( preOriginMatchChar ) ) //上一个为小写或符号
96+ {
97+ currentCompletionScore += SpecialMatchSocre ;
98+ }
9399 }
94- else
100+ else if ( char . IsLower ( originMatchChar ) ) //当前为小写字母匹配
95101 {
96- currentCompletionScore += scoreRewards ; //普通匹配
102+ if ( char . IsPunctuation ( preOriginMatchChar ) ) //上一个为符号
103+ {
104+ currentCompletionScore += SpecialMatchSocre ;
105+ }
97106 }
98107
99- if ( matchIndex == 0 ) //首字母匹配
100- {
101- currentCompletionScore += UpperMatchSocre ;
102- }
108+ currentCompletionScore += scoreRewards ; //普通匹配
103109
104110 scoreRewards ++ ; //增加匹配分
105111 charsMatchedCount ++ ;
112+ preOriginMatchChar = originMatchChar ;
106113 break ;
107114 }
108115 }
@@ -118,6 +125,11 @@ public static int CalculateMatchScore(string inputText, string matchText, out in
118125 if ( charsMatchedCount == matchLength ) //完整匹配目标项
119126 {
120127 currentCompletionScore *= 12 * inputLength ;
128+ //大小写完全匹配翻倍
129+ if ( string . Equals ( inputText , matchText , StringComparison . Ordinal ) )
130+ {
131+ currentCompletionScore *= 2 ;
132+ }
121133 }
122134 else
123135 {
0 commit comments