telescope.nvim
telescope.nvim copied to clipboard
Fix LSP References Single-Result Jump Behavior
Description
When there is only a single result for a call to lsp_references, the previous cursor position is not added to the jumplist. This is inconsistent with the behavior of other Telescope built-ins.
This PR changes the implementation of the lsp.references method to use the list_or_jump helper function already in use for other LSP-related items (e.g. definitions, type_definitions, implementations). It also adds an optional results filter to list_or_jump via the results_filter attribute in opts.
Type of change
- Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration
- [ ] Find a symbol that has a single usage & call
require('telescope.builtin').lsp_references(). Try jumping back (via<C-o>) to the previous cursor position. - [ ] Confirm symbols with multiple usages work as intended.
Configuration:
- Neovim version (nvim --version): v0.8.1
- Operating system and version: Debian (testing)
Checklist:
- [x] My code follows the style guidelines of this project (stylua)
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation (lua annotations)
@Conni2461 sorry for the ping, but do I need to directly assign someone for the CI workflow and/or a review? Thanks!
I am sorry about the late review. There is no excuse i should have done it a long time ago :|
Thanks for the PR :) I've also thought that using the same function should be possible, so thanks for implementing it.
I've done a quick review. opts.results_filter kinda gives us a new feature that should be documented for the all pickers that use list_or_jump. Do you know how to do that?
To fix CI you just have to rebase your branch because we fixed the tests already on master. There should be no conflicts, so rebase should be straight forward
No worries on the delay! End of the year is always a busy time :)
I added docs for the affected pickers, but I'm not sure if anything else needs to be done besides the CI pushing the changes to the branch once the workflow permissions are granted. Also, I noticed a subtle bug with my initial implementation -- if someone passed in a results_filter fn for the lsp_references picker, it would be discarded in favor of the "remove current line" filter. I added some extra logic to run both filters if available.
Let me know if you need anything else!
Thank you for the work on this @Conni2461 and @jls83!
This PR looks stale.
Anything I could do to help?
Upping this one :point_up: could also help if need be :)
uff thats a 2022 PR, i'll finish it this weekend. thanks for the ping
@Conni2461 I fixed up my branch with master & made some of the requested changes. Let me know if you need anything else!