Skip to content

Commit

Permalink
🐛 NPE problem #65
Browse files Browse the repository at this point in the history
  • Loading branch information
tuchg committed Oct 20, 2022
1 parent 0d8fff5 commit cc4303a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ChineseLookupElement(
* 据此进行文本匹配
*/
override fun getLookupString(): String {
return original!!
return original ?: ""
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ class ChinesePrefixMatcher(prefixMatcher: PrefixMatcher) : PlainPrefixMatcher(pr


override fun cloneWithPrefix(prefix: String) =
if (prefix == this.prefix) this else ChinesePrefixMatcher(originalMatcher!!.cloneWithPrefix(prefix))
if (prefix == this.prefix || originalMatcher == null) this else ChinesePrefixMatcher(
originalMatcher!!.cloneWithPrefix(
prefix
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ open class ChineseCompletionContributor() : CompletionContributor() {
).maxByOrNull { str -> countContainsSomeChar(str.toLowerCase(), prefix) }
closest?.let {
//todo 完全匹配的优先级需提高
val priority = if (prefix.isNotEmpty()) StringUtil.difference(it, prefix) * 100.0 else 5.0
val priority = if (prefix.isNotEmpty()) StringUtil.difference(it, prefix) * 2.0 else 1.0
// 追加补全列表
renderElementHandle(element, it, priority, resultSet, r)
}
Expand All @@ -66,6 +66,8 @@ open class ChineseCompletionContributor() : CompletionContributor() {
.copyFrom(element)
val withPriority = PrioritizedLookupElement.withPriority(chineseLookupElement, priority)
val wrap = CompletionResult.wrap(withPriority, r.prefixMatcher, r.sorter)
rs.passResult(wrap!!)
};
if (wrap != null) {
rs.passResult(wrap)
}
}
}

0 comments on commit cc4303a

Please sign in to comment.