gpt4 book ai didi

visual-studio-code - 如何选择符号 onWorkspaceSymbol

转载 作者:行者123 更新时间:2023-12-04 17:41:06 24 4
gpt4 key购买 nike

我正在使用语言服务器协议(protocol)为 visual studio code 开发一个扩展,并且包括对“转到工作区中的符号”的支持。我的问题是我不知道如何选择比赛......实际上我使用了我写的这个函数:

function IsInside(word1, word2)
{
var ret = "";
var i1 = 0;
var lenMatch =0, maxLenMatch = 0, minLenMatch = word1.length;
for(var i2=0;i2<word2.length;i2++)
{
if(word1[i1]==word2[i2])
{
lenMatch++;
if(lenMatch>maxLenMatch) maxLenMatch = lenMatch;
ret+=word1[i1];
i1++;
if(i1==word1.length)
{
if(lenMatch<minLenMatch) minLenMatch = lenMatch;
// Trying to filter like VSCode does.
return maxLenMatch>=word1.length/2 && minLenMatch>=2? ret : undefined;
}
} else
{
ret+="Z";
if(lenMatch>0 && lenMatch<minLenMatch)
minLenMatch = lenMatch;
lenMatch=0;
}
}
return undefined;
}

如果 word1 在 word2 内,则返回 sortText,否则未定义。我的问题是这样的情况:

**strong text**

我的算法看到“aller”在 CallServer 中,但界面没有按预期标记它。

为此我必须使用图书馆或其他东西吗? VSCode 的代码又大又复杂,我不知道从哪里开始寻找这些信息...

最佳答案

provideWorkspaceSymbols() 的 VSCode API 文档提供了以下指导(我认为您的示例没有违反):

The query-parameter should be interpreted in a relaxed way as the editor will apply its own highlighting and scoring on the results. A good rule of thumb is to match case-insensitive and to simply check that the characters of query appear in their order in a candidate symbol. Don't use prefix, substring, or similar strict matching.

这些文档是为响应 this discussion 而添加的,其中有人遇到与您非常相似的问题。

简要查看 VSCode 源代码,在内部它似乎使用 filters.matchFuzzy2() 进行突出显示(参见 herehere)。我不认为它在 API 中公开,因此如果您希望行为完全匹配,您可能必须复制它。

关于visual-studio-code - 如何选择符号 onWorkspaceSymbol,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54456703/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com