Rod*_*eck 7 visual-studio-code vscode-extensions
我正在尝试将设置添加到 Visual Studio Code 扩展 (vscode-powershell)
我编辑了settings.ts文件以添加:一个新界面:
export interface ICertificateSettings {
certificateSubject?: string;
}
Run Code Online (Sandbox Code Playgroud)
我编辑了ISettings界面以添加我的界面
export interface ISettings {
useX86Host?: boolean,
enableProfileLoading?: boolean,
scriptAnalysis?: IScriptAnalysisSettings,
developer?: IDeveloperSettings,
certificate?: ICertificateSettings
}
Run Code Online (Sandbox Code Playgroud)
然后加载函数添加我的默认设置和返回值:
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)
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我使用调试面板运行我的扩展然后启动时,我在 PowerShell 部分看不到我的新“证书”设置。
你知道我缺少什么吗?
是的,您缺少对 的添加package.json,因为那是实际定义配置选项的内容。Typescript 代码只是将它们读出。具体来说,您需要添加一个contributes.configuration部分。有关示例,请参阅 中的相应部分vscode-powershell/package.json。
你的会是这样的(未经测试):
{
...
"contributes": {
...
"configuration": {
"type": "object",
"title": "myPluginId", // whatever it really is
"properties": {
"certificate.certificateSubject": {
"type": ["string", "null"],
"default": null,
"description": "..."
}
}
},
...
},
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1918 次 |
| 最近记录: |