vscode扩展QuickPick ActiveItems不工作
const q = vscode.window.createQuickPick();
q.items = [{ label: "1" }, { label: "2" }];
q.activeItems = [{ label: "2" }];
q.show();
根据我对VSCODE扩展API文档的了解。
/**
* Active items. This can be read and updated by the extension.
*/
activeItems: readonly T[];
当QuickPick显示时,它应该活跃“ 2”项目。 但是我发现ActiveItems将在show()方法之后重置; 我不知道为什么并且在互联网中找不到同样的问题,
const q = vscode.window.createQuickPick();
q.items = [{ label: "1" }, { label: "2" }];
q.activeItems = [{ label: "2" }];
q.show();
Based on my understand of vscode extension api doc.
/**
* Active items. This can be read and updated by the extension.
*/
activeItems: readonly T[];
it should active "2" item when quickpick is showing.
But I found activeItems will reset after show() method;
I dont know why and cant find any same issue in the internet,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来A bug在这里影响行为
我的解决方案是设置活动性项目< em> 调用表演方法。似乎代码确实参考了比较。
所以
it seems that a bug is impacting behavior here
my solution was to set the active items after calling the show method. Also it seems the code does reference comparisons.
So
我遇到了同样的问题,我认为我发现了潜在的问题。看起来基于
项目
的成员资格的基础VSCODE逻辑将使您的分配过滤到ActiveItems
,看起来它可能是身份检查而不是结构性检查。将我的代码更改为类似:
似乎获得了预期的行为(允许为QuickPick设置初始活动项目)。
因此,在您的情况下,您可以尝试:
我知道这是一年后,但这可能会帮助其他偶然发现这个问题的人:)
I ran into this same issue and I think I've found the underlying problem. It looks like the underlying VSCode logic will filter your assignment to
activeItems
based on membership initems
, and it looks like it may be an identity check rather than a structural check.Changing my code to be something like:
seemed to get the expected behavior (allowing an initial active item to be set for the QuickPick).
So in your case you could try:
I know it's a year later but maybe this will help someone else who stumbles upon this issue :)