Sathish V
Sathish V

Reputation: 378

Where to store the extension related information in vscode

I am creating an extension, in which I need to get a string from user and store it, so that in future I will give a suggestion through quickdropbox. Now, which is the genuine way to store the user input data? I seen the Project manager extension source. There the user input project name is stored in project.json which is located in %APPDATA%\Code\User folder. Is this right way to store? sorry for my poor English.

Upvotes: 6

Views: 2994

Answers (1)

alefragnani
alefragnani

Reputation: 3153

If you don't want the user to see this string after you store (like in User Settings, you should use context.globalState. I made another extension that does something like your scenario, it's called Tagged Comment.

This is how it stores the value:

context.globalState.update('lastTagged', str);

This is how it loads the value:

let lastTagged = context.globalState.get('lastTagged', '');

Upvotes: 12

Related Questions