xdebug / vscode-php-debug

PHP Debug Adapter for Visual Studio Code 🐞⛔
MIT License
779 stars 178 forks source link

fix: Fixes erroneous non-null args.env check #872

Closed Keanu73 closed 1 year ago

Keanu73 commented 1 year ago

Upon further investigation of #788 and #860, I found that, by default, if "env" is not specified, VSCode does not set it to undefined, but sets it to an empty object {}.

Code_2022-12-09_17-38-52

Code_2022-12-09_17-38-47

The extension code here checks if args.env is not equal to undefined. By logic, undefined is not equal to {} (thanks JavaScript..), thus, with the default "Listen for Xdebug" configuration launched, it will still throw this error needlessly.

Code_2022-12-09_17-38-42

I've made a fix for this by, instead, checking if args.env is equal to true (which is the equivalent of !== undefined) - and, also checks if there are more than 0 keys in the object, a.k.a the object is not empty. I can confirm that the debugger now runs normally with the default "Listen for Xdebug" configuration in my project.

codecov[bot] commented 1 year ago

Codecov Report

Merging #872 (367087d) into main (f2546fd) will increase coverage by 0.06%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #872      +/-   ##
==========================================
+ Coverage   69.90%   69.96%   +0.06%     
==========================================
  Files          12       12              
  Lines        1834     1838       +4     
  Branches      375      379       +4     
==========================================
+ Hits         1282     1286       +4     
  Misses        552      552              
Impacted Files Coverage Δ
src/phpDebug.ts 63.83% <100.00%> (+0.21%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 1.29.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: