VS Code IntelliSense 不适用于模块(PowerShell 5.1)

VS Code IntelliSense 不适用于模块(PowerShell 5.1)

我知道很多人都在报告 vscode intelliSense 的各种问题,而且该功能充其量也只是有缺陷而已(?),但我还是会尝试提出一个问题。因为 - 在大多数情况下,它对我来说运行良好。直到最近我尝试更改一些有关终端、默认终端配置文件、扩展的行为/可见性等的设置。

IntelliSense 仍适用于内置 cmdlet,但不适用于其他模块。即使在明确导入模块并验证 cmdlet 是否存在后,建议/自动完成或其他任何功能都不起作用。我应该指出,这仅在编辑器中有效 - 在终端中它可以正常工作。此外,使用 PS7 时它似乎工作得更好,但我仍然严重依赖 PS5。

我尝试撤销对设置所做的更改,但遗憾的是没有成功。此外,我不能肯定地说在我开始弄乱设置之前它确实有效,但我相信它有效。然而,我最近重新安装了我的电脑,而且当我这样做时,我将模块安装在我的个人用户范围而不是 AllUsers(Program Files)范围内 - 所以有很多因素,我不知道到底是什么导致了这种情况...... :-) 但不久前它就起作用了。

只是想看看是否有人有什么建议,因为这实在是无法忍受。TIA


编辑 1:如果我将模块专门导入“PowerShell Extension”终端,它看起来是有效的。这让我感觉很尴尬,因为我使用 PS v.5.1 的自定义终端配置文件。这是设计使然吗?这也很烦人,因为我的强迫症真的很喜欢干净的视图 - 这就是为什么我在用户设置中有“startInBackground:true”和“showOnStartup:false”。我可能对此了解有限,我不知道...任何帮助或提示都将不胜感激。

我的最终目标是只显示一个(自定义)终端配置文件,并且让智能感知同时在终端和编辑器中工作:

终极终端视图

但这会导致上述问题:

编辑器 IntelliSense 不工作

编辑器 IntelliSense 不工作

反过来,据我所知,只能通过启用“PowerShell 扩展”的可见性,然后导入该配置文件中特定的模块来解决此问题。但是,这会使终端配置文件列表比我想要的更混乱,而且我需要 2 个运行配置文件,因为扩展默认为 PS 7,而我无法使用它……

混乱的终端资料列表

我的设置(我可能测试了不同的变化,并且弄乱了注释的设置等等......):

    {
    "git.autofetch": true,
    "git.confirmSync": false,
    "git.autoRepositoryDetection": false,
    "workbench.colorTheme": "Monokai",
    "workbench.startupEditor": "none",
    "workbench.list.openMode": "doubleClick",
    "workbench.editor.enablePreview": false,
    "editor.bracketPairColorization.enabled": true,
    "editor.minimap.enabled": true,
    "editor.cursorStyle": "line-thin",
    "files.defaultLanguage": "powershell",

    "powershell.promptToUpdatePowerShell": false,
    "powershell.integratedConsole.focusConsoleOnExecute": false,
    "powershell.integratedConsole.showOnStartup": false,
    "powershell.integratedConsole.startInBackground": true,
    "powershell.integratedConsole.suppressStartupBanner": true,
    "powershell.startAutomatically": true,
    "terminal.integrated.shellIntegration.enabled": true,
    
    
    // "powershell.scriptAnalysis.enable": true,
    // "powershell.enableProfileLoading": true,
    // "editor.suggestSelection": "first",
    // "extensions.autoUpdate": true,
    // "powershell.developer.editorServicesLogLevel": "Verbose",
    // "editor.formatOnSave": true,
    // "editor.mouseWheelZoom": true,
    // "editor.tabCompletion": "on",
    // "terminal.integrated.rightClickBehavior": "default",
    // "window.title": "${activeEditorLong}",
    // "powershell.powerShellExePath": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    // "powershell.scriptAnalysis.settingsPath": "ScriptAnalyzerSettings.psd1",


    // https://code.visualstudio.com/docs/terminal/profiles
    // https://stackoverflow.com/questions/73845252/new-way-to-specify-powershell-7-in-visual-studio-code
    "terminal.integrated.profiles.windows": {
        "PowerShell5": {
            "overrideName": true,
            "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
            "icon": "terminal-powershell",
            "color": "terminal.ansiYellow",
            "args": [
                "-NoLogo"
            ]
        },
        "PowerShell7": {
            "overrideName": true,
            "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
            "icon": "terminal-powershell",
            "color": "terminal.ansiGreen",
            "args": [
                "-NoLogo"
            ]
        },
        "Command Prompt": null,
        "Git Bash": null,
        "JavaScript Debug Terminal": null,
        "PowerShell": null,
        "Ubuntu-18.04 (WSL)": null
    },
    "terminal.integrated.defaultProfile.windows": "PowerShell5"
    }

相关内容