Skip to content

Highlight binary expressions on operator hover - #5306

Closed
Sano007 wants to merge 1 commit into
meta:mainfrom
Sano007:feature/5104-support-binary-operator-highlight-range
Closed

Sano007 wants to merge 1 commit into
meta:mainfrom
Sano007:feature/5104-support-binary-operator-highlight-range

Conversation

@Sano007

@Sano007 Sano007 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Return the enclosing binary expression range with operator hover responses so editors highlight the complete operation instead of only showing hover content.

Summary

When hovering over a binary operator, Pyrefly already displays the corresponding
operator method, but it does not provide a range for the editor to highlight.

This change returns the range of the enclosing binary expression. For example,
hovering over | in x = a | b now highlights a | b.

Fixes #5104

  • I am a human, and I fully understand the code I am submitting.

Test Plan

  • cargo test test::lsp::hover
  • ./test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension
  • Built Pyrefly locally and configured VS Code to use the local binary.
    Verified that hovering over | in x = a | b highlights a | b.

@meta-cla

meta-cla Bot commented Oct 21, 2026

Copy link
Copy Markdown

Hi @Sano007!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Oct 21, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@github-actions

This comment has been minimized.

@stroxler stroxler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cool, thanks!

Could you rebase this? I think it looks good, but our PR import doesn't run on a PR made before the CLA is singed, ususally rebasing will trigger an import that we can then merge

@Sano007

Sano007 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Sure, I'll do it right now

Return the enclosing binary expression range with operator hover responses so
editors highlight the complete operation instead of only showing hover content.
@Sano007
Sano007 force-pushed the feature/5104-support-binary-operator-highlight-range branch from 806a949 to 6a3cde3 Compare October 29, 2026 19:25
@github-actions github-actions Bot added size/s and removed size/s labels Oct 29, 2026
@meta-codesync

meta-codesync Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D128397374. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@stroxler stroxler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in a9fc1dd Nov 2, 2026
meta-codesync Bot pushed a commit that referenced this pull request Nov 2, 2026
Summary:
Subscript hover must not replace the type of an operator inside its index expression. Let the innermost operator resolve through the existing hover path while retaining bracket, literal, and identifier hovers.

This keeps the hover contents aligned with the expression highlighted by PR #5306. It also covers boolean, unary, and comparison operators through the same ownership rule. No type-checking diagnostics change.

___

landed-with-radar-review

Differential Revision: D129122405

fbshipit-source-id: aae0e3b5ef1746bd16ec1c25fad3049e7501192b
@meta-codesync meta-codesync Bot added the Merged label Nov 2, 2026
@meta-codesync

meta-codesync Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in a9fc1dd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support binary operator highlight range

4 participants