跳到主要内容

上下文键(Context Key)

编辑器维护的一块命名状态,when 子句读取它。内置键描述焦点、语言、只读、操作系统等,例如 editorHasSelection、resourceScheme、isWeb。

扩展通过命令 setContext 写入自己的键。键值可以是布尔、数字、字符串,in 运算符还要求数组或普通对象。

键名应带扩展前缀。菜单不出现时,先用 Inspect Context Keys 看这个键现在的值。

参考:https://code.visualstudio.com/api/references/when-clause-contexts