diff options
author | Aleksey Kladov <[email protected]> | 2020-04-24 22:40:41 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-04-25 10:59:18 +0100 |
commit | b1d5817dd18b7b5fc102a63b084b1ee7ff4f9996 (patch) | |
tree | e5d136c5ba4a6ba96aeeb423e6e3f64ca7cea3f9 /crates/ra_assists/src/handlers/add_custom_impl.rs | |
parent | 27a7718880d93f55f905da606d108d3b3c682ab4 (diff) |
Convert code to text-size
Diffstat (limited to 'crates/ra_assists/src/handlers/add_custom_impl.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/add_custom_impl.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index 15f9b216b..7bb90dba3 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs | |||
@@ -2,7 +2,7 @@ use ra_syntax::{ | |||
2 | ast::{self, AstNode}, | 2 | ast::{self, AstNode}, |
3 | Direction, SmolStr, | 3 | Direction, SmolStr, |
4 | SyntaxKind::{IDENT, WHITESPACE}, | 4 | SyntaxKind::{IDENT, WHITESPACE}, |
5 | TextRange, TextUnit, | 5 | TextRange, TextSize, |
6 | }; | 6 | }; |
7 | use stdx::SepBy; | 7 | use stdx::SepBy; |
8 | 8 | ||
@@ -71,7 +71,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
71 | 71 | ||
72 | let cursor_delta = if has_more_derives { | 72 | let cursor_delta = if has_more_derives { |
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() - TextUnit::from_usize(new_attr_input_len) | 74 | input.syntax().text_range().len() - TextSize::from_usize(new_attr_input_len) |
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); |
@@ -81,13 +81,13 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
81 | .next_sibling_or_token() | 81 | .next_sibling_or_token() |
82 | .filter(|t| t.kind() == WHITESPACE) | 82 | .filter(|t| t.kind() == WHITESPACE) |
83 | .map(|t| t.text_range()) | 83 | .map(|t| t.text_range()) |
84 | .unwrap_or_else(|| TextRange::from_to(TextUnit::from(0), TextUnit::from(0))); | 84 | .unwrap_or_else(|| TextRange::new(TextSize::from(0), TextSize::from(0))); |
85 | edit.delete(line_break_range); | 85 | edit.delete(line_break_range); |
86 | 86 | ||
87 | attr_range.len() + line_break_range.len() | 87 | attr_range.len() + line_break_range.len() |
88 | }; | 88 | }; |
89 | 89 | ||
90 | edit.set_cursor(start_offset + TextUnit::of_str(&buf) - cursor_delta); | 90 | edit.set_cursor(start_offset + TextSize::of(&buf) - cursor_delta); |
91 | buf.push_str("\n}"); | 91 | buf.push_str("\n}"); |
92 | edit.insert(start_offset, buf); | 92 | edit.insert(start_offset, buf); |
93 | }) | 93 | }) |