首页 > 解决方案 > 编辑器面板中的visual-studio-code Powershell命令自动完成不起作用

问题描述

我刚刚开始使用 Visual Studio Code 来处理 Powershell。我已经加载了 powershell 扩展,当我连接到 Exchange 时,cmdlet 的自动完成功能在集成的 powershell 窗口中工作,但它在 to peditor 面板中不起作用。如何让 cmdlet 自动完成或智能感知在编辑器面板中工作?谢谢!

标签: powershellvisual-studio-codecommandintellisense

解决方案


您不会说您是否将 VSCode 环境配置为使 PowerShell 成为默认语言。如果您查看编辑器的右上角,它将告诉您当前设置的语言。显示您的用户设置。在您的用户设置中,您应该有这样的行(只是我的一个示例,根据您的用例需要进行调整 - 有关 VSCode 用户设置的详细信息,请参阅文档。)...</p>

"extensions.autoUpdate": true,
"files.defaultLanguage": "powershell",
"powershell.scriptAnalysis.enable": true,
"powershell.startAutomatically": true,
"powershell.integratedConsole.focusConsoleOnExecute": false,
"powershell.enableProfileLoading": true,
"powershell.developer.editorServicesLogLevel": "Verbose",
"editor.formatOnSave": true,
"editor.minimap.enabled": false,
"editor.mouseWheelZoom": true,
"editor.tabCompletion": "on",
"editor.suggestSelection": "first",
"terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe",
"terminal.integrated.rightClickBehavior": "default",
"window.title": "${activeEditorLong}",
"powershell.powerShellExePath": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"powershell.scriptAnalysis.settingsPath": "ScriptAnalyzerSettings.psd1",
"workbench.startupEditor": "newUntitledFile",
"editor.cursorStyle": "line-thin",
"shellLauncher.shells.windows": [
    {
        "shell": "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
        "label": "PowerShell 5.1"
    },
    {
        "shell": "C:\\Program Files\\PowerShell\\6\\pwsh.exe",
        "label": "PowerShell 6.0"
    },
    {
        "shell": "C:\\Windows\\System32\\cmd.exe",
        "label": "cmd"
    },
    {
        "shell": "C:\\Program Files\\Git\\bin\\bash.exe",
        "label": "Git bash"
    },
    {
        "shell": "C:\\Windows\\System32\\bash.exe",
        "label": "WSL Bash"
    },

VSCode 因无缘无故停止智能感知而臭名昭著(这是我的第一把控),但在大多数情况下,您所要做的就是退格到命令的开头并重试,或者使用 CRTL+空格键智能感知踢它,或键入重新加载。

再一次,这一直发生在我身上,上面的事情又回来了。这很烦人,但就是这样。


推荐阅读