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

代码补全中变量只有1个字符会存在问题 #4341

Closed
liukonghe opened this issue Jul 15, 2020 · 0 comments
Closed

代码补全中变量只有1个字符会存在问题 #4341

liukonghe opened this issue Jul 15, 2020 · 0 comments

Comments

@liukonghe
Copy link

liukonghe commented Jul 15, 2020

image

无法出现a变量的补全。
查看源码后我发现问题在于ext-language_tools.js
function wordDistance(doc, pos) {
var prefixPos = getWordIndex(doc, pos);
var words = doc.getValue().split(splitRegex);
var wordScores = Object.create(null);

var currentWord = words[prefixPos];

words.forEach(function(word, idx) {
    if (!word || idx === words.length-1) return;

    var distance = Math.abs(prefixPos - idx);
    var score = words.length - distance;
    if (wordScores[word]) {
        wordScores[word] = Math.max(score, wordScores[word]);
    } else {
        wordScores[word] = score;
    }
});
return wordScores;

}
我将 if (!word || word === currentWord) return;代码更改为if (!word || idx === words.length-1) return;
现在变量只有1个字符的补全就没问题了
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant