From 002529937075bd69d7f71483d798d6e4f43d1de9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 19 Jul 2019 20:55:32 +0300 Subject: sane indexing in text --- crates/ra_assists/src/remove_dbg.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/remove_dbg.rs b/crates/ra_assists/src/remove_dbg.rs index c330bc827..5657ee4b8 100644 --- a/crates/ra_assists/src/remove_dbg.rs +++ b/crates/ra_assists/src/remove_dbg.rs @@ -36,11 +36,10 @@ pub(crate) fn remove_dbg(mut ctx: AssistCtx) -> Option let macro_content = { let macro_args = macro_call.token_tree()?.syntax().clone(); - let range = macro_args.range(); - let start = range.start() + TextUnit::of_char('('); - let end = range.end() - TextUnit::of_char(')'); - macro_args.text().slice(start..end).to_string() + let text = macro_args.text(); + let without_parens = TextUnit::of_char('(')..text.len() - TextUnit::of_char(')'); + text.slice(without_parens).to_string() }; ctx.add_action(AssistId("remove_dbg"), "remove dbg!()", |edit| { -- cgit v1.2.3