Reputation: 363
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?
Upvotes: 7
Views: 5759
Reputation: 12749
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": "..."
}
}
},
...
},
...
}
Upvotes: 4