microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.33k stars 28.59k forks source link

Shell Integration error - Unexpected Token '??' in expression or statement #157417

Closed OMikkel closed 2 years ago

OMikkel commented 2 years ago

Type: Bug

Just tried to install the shell integration, however when i add: if ($env:TERM_PROGRAM -eq "vscode") { . "$(code --locate-shell-integration-path pwsh)" } to my PowerShell Profile it spits out an error everytime i open vscode.

My shell profile is completely standard apart from the vscode shell integration snippet.

Error looks like this:

At C:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\browser\media\shellIntegration.ps1:39 char:49
+             $CommandLine = $LastHistoryEntry.CommandLine ?? ""
+                                                          ~~
Unexpected token '??' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

VS Code version: Code 1.70.0 (da76f93349a72022ca4670c1b84860304616aaa2, 2022-08-04T04:38:16.462Z) OS version: Windows_NT x64 10.0.19044 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz (6 x 3696)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|31.94GB (19.05GB free)| |Process Argv|--crash-reporter-id 1e96fddb-eb32-4c94-a3d9-3571a5acb539| |Screen Reader|no| |VM|0%|
Extensions (31) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|3.0.2 cypress-snippets|and|1.2.0 vscode-tailwindcss|bra|0.8.6 path-intellisense|chr|2.8.1 gitlens|eam|12.1.2 vscode-html-css|ecm|1.13.1 prettier-vscode|esb|9.5.0 auto-rename-tag|for|0.1.10 copilot|Git|1.38.6394 copilot-labs|Git|0.2.221 discord-vscode|icr|5.8.0 fix-relative-imports-to-baseurl|iul|1.1.9 dotenv|mik|1.0.1 inline-fold|moa|0.1.6 vscode-docker|ms-|1.22.1 vscode-kubernetes-tools|ms-|1.3.10 remote-containers|ms-|0.241.3 remote-ssh|ms-|0.84.0 remote-ssh-edit|ms-|0.80.0 remote-wsl|ms-|0.66.3 vscode-remote-extensionpack|ms-|0.21.0 material-icon-theme|PKi|4.19.0 vscode-thunder-client|ran|1.17.1 vscode-rapidapi-client|Rap|1.3.0 vscode-yaml|red|1.9.1 LiveServer|rit|5.7.5 gitmoji-vscode|sea|1.1.2 php-formatter|Sop|0.2.4 vscode-status-bar-format-toggle|tom|3.1.1 sort-lines|Tyr|1.9.1 errorlens|use|3.6.0 (1 theme extensions excluded)
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 vscscmwlcmt:30465135 cppdebug:30492333 pylanb8912cf:30529770 vsclangdc:30486549 c4g48928:30535728 hb751961:30541207 dsvsc012:30540252 ```
Tyriar commented 2 years ago

Looks like the null coalescing operator is pwsh 7+ only, I'd recommend upgrading pwsh if possible which should fix the issue in the meantime.