helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.16k stars 2.46k forks source link

"Remove `dbg!` macro" code action for Rust #9631

Open tgross35 opened 7 months ago

tgross35 commented 7 months ago

VSCode has a very useful action to remove dbg! macros:

image

Helix doesn't seem to have the same option:

image

I think this is in RA rather than VSCode directly https://github.com/rust-lang/rust-analyzer/blob/dba59970bcccfb3c6fc16ea0d0d79da875f22316/crates/ide-assists/src/lib.rs#L362, is it possible to expose in Helix?

helix 23.10 (f6021dd0)

gabydd commented 7 months ago

I am able to get this macro when I fully select the dbg! call but not when my cursor is in the range, which is probable because here: https://github.com/rust-lang/rust-analyzer/blob/dba59970bcccfb3c6fc16ea0d0d79da875f22316/crates/ide-assists/src/handlers/remove_dbg.rs#L25 they check if there is no selection but we always have a selection that we send

tgross35 commented 7 months ago

Hm, the only extra options that show up for me are the usual refactoring options. Does yours only work in certain circumstances?

image
gabydd commented 7 months ago

Sorry you need to select the whole call so what's inside the () as well plus the last )

willhansen commented 7 months ago

I am able to get this macro when I fully select the dbg! call but not when my cursor is in the range, which is probable because here: https://github.com/rust-lang/rust-analyzer/blob/dba59970bcccfb3c6fc16ea0d0d79da875f22316/crates/ide-assists/src/handlers/remove_dbg.rs#L25 they check if there is no selection but we always have a selection that we send

Are there lots of rust-analyzer features that do this? How much convenience are we missing out on by always sending a selection?

Edit: looks like there's a handful

image