diff options
Diffstat (limited to 'crates/ra_assists/src/handlers/add_custom_impl.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/add_custom_impl.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index 7bb90dba3..4ea26a550 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs | |||
@@ -60,7 +60,6 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
60 | .collect::<Vec<SmolStr>>(); | 60 | .collect::<Vec<SmolStr>>(); |
61 | let has_more_derives = !new_attr_input.is_empty(); | 61 | let has_more_derives = !new_attr_input.is_empty(); |
62 | let new_attr_input = new_attr_input.iter().sep_by(", ").surround_with("(", ")").to_string(); | 62 | let new_attr_input = new_attr_input.iter().sep_by(", ").surround_with("(", ")").to_string(); |
63 | let new_attr_input_len = new_attr_input.len(); | ||
64 | 63 | ||
65 | let mut buf = String::new(); | 64 | let mut buf = String::new(); |
66 | buf.push_str("\n\nimpl "); | 65 | buf.push_str("\n\nimpl "); |
@@ -70,8 +69,9 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
70 | buf.push_str(" {\n"); | 69 | buf.push_str(" {\n"); |
71 | 70 | ||
72 | let cursor_delta = if has_more_derives { | 71 | let cursor_delta = if has_more_derives { |
72 | let delta = input.syntax().text_range().len() - TextSize::of(&new_attr_input); | ||
73 | edit.replace(input.syntax().text_range(), new_attr_input); | 73 | edit.replace(input.syntax().text_range(), new_attr_input); |
74 | input.syntax().text_range().len() - TextSize::from_usize(new_attr_input_len) | 74 | delta |
75 | } else { | 75 | } else { |
76 | let attr_range = attr.syntax().text_range(); | 76 | let attr_range = attr.syntax().text_range(); |
77 | edit.delete(attr_range); | 77 | edit.delete(attr_range); |