Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen and modify client messages to make code actions work #7876

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

StellaHuang95
Copy link
Contributor

fixes #7864

In the code action requests that VS client sends, the _vs_selectionRange is supposed to be the range property that Pylance can understand, so intercept the messages and modify the property to make code actions work.

codeaction-extractmethod

@StellaHuang95 StellaHuang95 requested a review from a team as a code owner April 19, 2024 18:49
Copy link

sonarcloud bot commented Apr 19, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

// We need to keep listening if debugging or haven't modified initialize yet
return Tuple.Create(data, !_modifiedInitialize || _isDebugging);
// For now we will keep listening since code action requests can be sent multiple times
return Tuple.Create(data, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know enough about this to say whether or not this change is valid. The rest looks good though :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This boolean value is used to determine whether to set the writeHandler of StreamIntercepter to null. Previously I think the intent was to modify the initialization message and stop the listening for perf considerations. My change is basically never set the writeHandler to null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my question would be if it's correct to change this behavior? Do the perf considerations no longer apply?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For code actions, at least I didn't notice any slowness. For other messages, it will bail out early since the if condition is not met.

@StellaHuang95 StellaHuang95 merged commit 2fa6014 into main Apr 19, 2024
5 checks passed
@StellaHuang95 StellaHuang95 deleted the codeAction branch April 19, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract method returns incorrect code
2 participants