Rank __init__.py results lower in workspace symbol search#2899
Rank __init__.py results lower in workspace symbol search#2899yslim-030622 wants to merge 1 commit intofacebook:mainfrom
Conversation
|
Hi @yslim-030622! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
samwgoldman
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary
Fixes #2465
When a symbol is re-exported from
__init__.py, workspace symbol search currently surfaces both the__init__.pyre-export and the original definition at equal priority. This means users often land on the re-export rather than the actual definition.This PR applies a single stable sort pass at the workspace symbol response site to push
__init__.pyresults after non-__init__.pyresults, while keeping both visible. The fuzzy relevance ordering within each group is preserved (Rust'ssort_by_keyis a stable sort).Scope: workspace symbol response path only (
workspace_symbols.rs). No changes to fuzzy matching, go-to-definition, shared export search logic, dedup behavior, or any other LSP feature.Changes
pyrefly/lib/lsp/non_wasm/workspace_symbols.rs: add a stable sort byis_init()after assembling the result list, with a single comment explaining the invariant.pyrefly/lib/test/lsp/lsp_interaction/workspace_symbol.rs: add regression testtest_workspace_symbol_prefers_non_init_resultthat opens both an implementation module and its package__init__.py, queries for the shared symbol, and asserts the ordering invariant holds.pyrefly/lib/test/lsp/lsp_interaction/test_files/tests_requiring_config/workspace_symbol_prefer_non_init/: minimal fixture package with one definition inimplementation.pyand one re-export in__init__.py.Test Plan
python3 test.py --no-test --no-conformance(fmt + lint) passes with no new errors introduced.cargo test workspace_symbol