如何 select symbols onWorkspaceSymbol
How to select symbols onWorkspaceSymbol
我正在使用语言服务器协议为 visual studio 代码开发一个扩展,并且包括对 "Go to symbol in workspace" 的支持。我的问题是我不知道如何 select 匹配...
其实我用的是我写的这个函数:
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 中,则 return sortText,否则未定义。我的问题是这样的情况:
我的算法看到'aller'在CallServer里面,但是接口没有标出来预期。
我必须使用图书馆或其他东西吗? VSCode 的代码又大又复杂,我不知道从哪里开始寻找这些信息...
VSCode 的 API provideWorkspaceSymbols()
文档提供了以下指导(我认为您的示例没有违反):
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()
进行突出显示(参见 here and here)。我不认为它在 API 中公开,因此如果您希望行为完全匹配,您可能必须复制它。
我正在使用语言服务器协议为 visual studio 代码开发一个扩展,并且包括对 "Go to symbol in workspace" 的支持。我的问题是我不知道如何 select 匹配... 其实我用的是我写的这个函数:
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 中,则 return sortText,否则未定义。我的问题是这样的情况:
我的算法看到'aller'在CallServer里面,但是接口没有标出来预期。
我必须使用图书馆或其他东西吗? VSCode 的代码又大又复杂,我不知道从哪里开始寻找这些信息...
VSCode 的 API provideWorkspaceSymbols()
文档提供了以下指导(我认为您的示例没有违反):
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()
进行突出显示(参见 here and here)。我不认为它在 API 中公开,因此如果您希望行为完全匹配,您可能必须复制它。