Forward source requests to debugpy as fallback#875
Draft
vidartf wants to merge 2 commits intoipython:anyiofrom
Draft
Forward source requests to debugpy as fallback#875vidartf wants to merge 2 commits intoipython:anyiofrom
vidartf wants to merge 2 commits intoipython:anyiofrom
Conversation
If the source cannot be looked up by the `path` argument, forward it to debugpy as it might be able to resolve it using the sourceReference field.
| reply['success'] = False | ||
| reply['message'] = 'source unavailable' | ||
| reply['body'] = {} | ||
| reply = await self._forward_message(message) |
Contributor
There was a problem hiding this comment.
Author
There was a problem hiding this comment.
I've had another go at this, trying to follow the spec more closely this time.
Give `sourceReference` priority. Not immediately clear which location should be given priority if soruceReference and source.sourceReference are both defined and different values. Spec says that they should be the same, so we can claim that this is not our problem.
r3m0t
reviewed
Mar 7, 2022
| } | ||
| source_ref = message["arguments"].get("sourceReference", 0) | ||
| if source_ref == 0: | ||
| message["arguments"].get("source", {}).get("sourceReference", 0) |
There was a problem hiding this comment.
Suggested change
| message["arguments"].get("source", {}).get("sourceReference", 0) | |
| source_ref = message["arguments"].get("source", {}).get("sourceReference", 0) |
There was a problem hiding this comment.
I tested this change and it worked with and without the suggested change (as VS Code passes the sourceReference in both places, SourceRequest.sourceReference and sourceRequest.source.sourceReference)
Author
There was a problem hiding this comment.
@r3m0t Thanks for testing. This change is meant to solve this for non-vscode usages as well 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If the source cannot be looked up by thepathargument, forward it to debugpy as it might be able to resolve it using the sourceReference field.EDIT: If the
sourceReferenceis non-zero, forward it to debugpy, as the specification requires the reference to be used in those cases.Proposed fix to #870.
TODO: Write some tests.