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

Jump to next/prev diagnostic in workspace (#3116) #4201

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dariooddenino
Copy link
Contributor

Implements functions and keybindings to move to next/previous/first/last diagnostic in the workspace as per #3116

Key Description
[w go to previous diagnostic in workspace
]w go to next diagnostic in workspace
[W go to first diagnostic in workspace
]W go to last diagnostic in workspace

I've also refactored some functions a little bit to reduce code duplication.

It's not entirely clear to me what's the clear cut between a function being in commands.rs or in commands/lsp.rs. I tried following the current code, but let me know if I have to move something.

There's some code repetition going on in get_next_diag_doc. I tried finding ways to handle the fact that the direction branches produce an Iter and a Rev, but the only solutions I found were based on external libraries not currenlty used (itertools, either).

Please, feel free to correct anything wrong here and suggest better practices.

@David-Else
Copy link
Contributor

I think ]d and ]D would make more sense, it seems to be the convention with document vs workspace: https://github.com/helix-editor/helix/blob/master/book/src/keymap.md#space-mode ... but D it is already used for Go to first diagnostic in document :( Maybe replace it as moving around the whole workspace is much more useful than just the first and last item in the document?

Changing diagnostics to w does not make sense to me.

@EpocSquadron
Copy link
Contributor

The space menu has g and G for diagnostics picker. Seems strange to have three different letters for related functionality.

@dariooddenino
Copy link
Contributor Author

Yeah I agree, ideally the same letter for everything would be better.

I wonder if the correct thing would be to replace the [ ] prefixes with something else, since right now they imply navigation inside the current document.
For example having <d >d <D >D, with < and > being the equivalent to the ones above for workspace movement. But then the question is if there are other keys that would benefit from this or not.

Having [D as goto previous diagnostic in workspace and ]D as goto next diagnostic in workspace is a very good idea.

@sudormrfbin
Copy link
Member

sudormrfbin commented Oct 11, 2022

The existing ]D binding for goto last diagnostic could be bound to ]<c-d> (] followed by ctrl-d) and the workspace variant could occupy ]D on the premise that the latter would be more commonly used.

Edit: Ah I didn't see that there were four workspace diagnostic keybind variants. In that case we could bind to ]]d, [[D, etc mimicking the document diagnostic keybinds but having an extra ] or [. This also communicates that ]]d is "more" than ]d which works quite nicely as a mnemonic.

@georgesboris
Copy link

New user here - the g and G on the space menu for diagnostics was zero intuitive. Since everyone here is also pushing for newer d based diagnostic commands shouldn't the current space menu shortcuts be revised maybe? I don't know how much deep the project is into no-breaking-changes yet - just a thought :)

@sudormrfbin
Copy link
Member

@georgesboris #4229.

@the-mikedavis the-mikedavis added A-helix-term Area: Helix term improvements S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 14, 2022
Implements functions and keybindings to move to next/previous/first/last diagnostic in the workspace
@dariooddenino dariooddenino force-pushed the 3116-go-to-next-lsp-diagnostic-in-worksp branch from 262ab16 to 83d4110 Compare October 17, 2022 08:50
@the-mikedavis the-mikedavis added S-waiting-on-review Status: Awaiting review from a maintainer. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 17, 2022
@andreytkachenko
Copy link
Contributor

That's would be awesome if it will jump to errors first and then to warnings and so on

@Tudyx
Copy link
Contributor

Tudyx commented Feb 13, 2024

What's the current blocker for this? I can help finish the work if needed.

Maybe we can provide only the commands for now, so users can bind them to whatever they want until we find a good default.

When making a change in a Rust codebase, I often just let the compiler guide me to see what other places are affected by my change. If I could jump from diagnostic to diagnostic across files, without opening the workspace diagnostic picker each time, it will be awesome.

@dariooddenino
Copy link
Contributor Author

What's the current blocker for this? I can help finish the work if needed.

Maybe we can provide only the commands for now, so users can bind them to whatever they want until we find a good default.

When making a change in a Rust codebase, I often just let the compiler guide me to see what other places are affected by my change. If I could jump from diagnostic to diagnostic across files, without opening the workspace diagnostic picker each time, it will be awesome.

Not sure, I think it's just a matter of no one having the time to review this since it's probably near the bottom of priorities.
You can pick it up without problems! I haven't been writing rust for a long while, and I'm not sure I want to get back into it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants