Skip to content
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

feat(coc-dictionary): adapt first char case when necessary #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/dictionary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ function filterWords(words, opt) {
let res = []
let { input } = opt
for (let word of words) {
if (!word.startsWith(input[0])) continue
if (word.length <= input.length) continue
let first = input[0]
if ([input, word].every(str => /^[A-Za-z]{1,}$/.test(str))) {
if (!word.startsWith(first.toLowerCase())) continue
let code = first.charCodeAt(0)
let upperCase = code <= 90 && code >= 65
word = upperCase ? word[0].toUpperCase() + word.slice(1) : word
} else if (!word.startsWith(first)) continue
res.push(word)
}
return res
Expand Down