vscode 扩展全局作用域中键的作用域 [英] Scoping of keys in vscode extension global scope

查看:35
本文介绍了vscode 扩展全局作用域中键的作用域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

vscode 扩展的上下文提供对 globalState 的访问是一个带有键/值对的 Memento 对象.我的问题是:每个扩展都有自己的纪念品对象,还是所有扩展都共享一个?只是想知道我是否需要使我的密钥更具体(例如,my.extension.foo),或者我是否可以使密钥保持简单(例如,foo).

The context of a vscode extension provides access to globalState which is a Memento object with key/value pairs. My question is: does each extension get its own memento object, or is there one shared by all extensions? Just wondering whether I need to make my keys more specific (e.g., my.extension.foo), or if I can keep the keys simple (e.g., foo).

推荐答案

它的范围仅限于您的扩展,因此您可以使它们保持简单:

It's scoped to your extension, so you can keep them simple:

然而,当扩展使用存储时,它总是将其数据存储在 1 个键下(扩展名称 + 扩展 ID).我们绝不允许在可能与其他密钥冲突的密钥下直接写入存储.

However, when an extension uses storage, it will always get it's data stored under 1 key (the extension name + extension ID). We never allow to write directly into storage under a key that could conflict with other keys.

(来源)

这篇关于vscode 扩展全局作用域中键的作用域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆