fix: Fixes erroneous non-null args.env check #872
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
{}
.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.
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.