I'm trying to add settings to a Visual Studio Code Extension (vscode-powershell)
I edited the settings.ts
file to add:
A new Interface:
export interface ICertificateSettings {
certificateSubject?: string;
}
I edited the ISettings
interface to add my Interface
export interface ISettings {
useX86Host?: boolean,
enableProfileLoading?: boolean,
scriptAnalysis?: IScriptAnalysisSettings,
developer?: IDeveloperSettings,
certificate?: ICertificateSettings
}
Then the load function to add my default settings and the return value:
export function load(myPluginId: string): ISettings {
let configuration = vscode.workspace.getConfiguration(myPluginId);
let defaultScriptAnalysisSettings = {
enable: true,
settingsPath: ""
};
let defaultDeveloperSettings = {
powerShellExePath: undefined,
bundledModulesPath: "../modules/",
editorServicesLogLevel: "Normal",
editorServicesWaitForDebugger: false
};
let defaultCertificateSettings = {
certificateSubject: ""
};
return {
useX86Host: configuration.get<boolean>("useX86Host", false),
enableProfileLoading: configuration.get<boolean>("enableProfileLoading", false),
scriptAnalysis: configuration.get<IScriptAnalysisSettings>("scriptAnalysis", defaultScriptAnalysisSettings),
developer: configuration.get<IDeveloperSettings>("developer", defaultDeveloperSettings),
certificate: configuration.get<ICertificateSettings>("certificate", defaultCertificateSettings)
}
}
But when I run my extension using the debug panel then launch, I can't see my new "certificate" setting in the PowerShell section.
Do you know what I am missing?
You can turn on Settings Sync using the Turn On Settings Sync... entry in the Manage gear menu at the bottom of the Activity Bar. You will be asked to sign in and what preferences you would like to sync; currently Settings, Keyboard Shortcuts, Extensions, User Snippets, and UI State are supported.
Yes, you're missing the additions to package.json
, since that is what actually defines the configuration options. The Typescript code merely reads them out. Specifically, you need to add a contributes.configuration
section. For an example, see the corresponding section in vscode-powershell/package.json
.
Yours would be something like (untested):
{
...
"contributes": {
...
"configuration": {
"type": "object",
"title": "myPluginId", // whatever it really is
"properties": {
"certificate.certificateSubject": {
"type": ["string", "null"],
"default": null,
"description": "..."
}
}
},
...
},
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With