Skip to content

Commit f986658

Browse files
committed
Fix target text_range
1 parent bfc0da6 commit f986658

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

crates/ide-assists/src/handlers/convert_attr_cfg_to_if.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ use crate::assist_context::{AssistContext, Assists};
3333
// }
3434
// ```
3535
pub(crate) fn convert_attr_cfg_to_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
36-
let (origin, cfg, stmt) = find_stmt(ctx.find_node_at_offset::<ast::Attr>()?)?;
36+
let cfg = ctx.find_node_at_offset::<ast::Attr>()?;
37+
let target = cfg.syntax().text_range();
38+
let (origin, cfg, stmt) = find_stmt(cfg)?;
3739

3840
if !is_cfg(&cfg) {
3941
return None;
@@ -45,7 +47,7 @@ pub(crate) fn convert_attr_cfg_to_if(acc: &mut Assists, ctx: &AssistContext<'_>)
4547
acc.add(
4648
AssistId::refactor_rewrite("convert_attr_cfg_to_if"),
4749
"Convert `#[cfg()]` to `if cfg!()`",
48-
cfg.syntax().text_range(),
50+
target,
4951
|builder| {
5052
let mut edit = builder.make_editor(origin.syntax());
5153

0 commit comments

Comments
 (0)