helix
helix copied to clipboard
Jump to next/prev diagnostic in workspace (#3116)
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.
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.
The space menu has g and G for diagnostics picker. Seems strange to have three different letters for related functionality.
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.
~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.
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 :)
@georgesboris https://github.com/helix-editor/helix/pull/4229.
That's would be awesome if it will jump to errors first and then to warnings and so on
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.
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 :smile: