From b1d5817dd18b7b5fc102a63b084b1ee7ff4f9996 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 24 Apr 2020 23:40:41 +0200 Subject: Convert code to text-size --- crates/ra_assists/src/handlers/add_new.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_assists/src/handlers/add_new.rs') diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 240b19fa3..0698cce88 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs @@ -3,7 +3,7 @@ use ra_syntax::{ ast::{ self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, }, - TextUnit, T, + TextSize, T, }; use stdx::{format_to, SepBy}; @@ -77,16 +77,16 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option { .text_range() .end(); - Some((start, TextUnit::from_usize(1))) + Some((start, TextSize::from_usize(1))) }) .unwrap_or_else(|| { buf = generate_impl_text(&strukt, &buf); let start = strukt.syntax().text_range().end(); - (start, TextUnit::from_usize(3)) + (start, TextSize::from_usize(3)) }); - edit.set_cursor(start_offset + TextUnit::of_str(&buf) - end_offset); + edit.set_cursor(start_offset + TextSize::of(&buf) - end_offset); edit.insert(start_offset, buf); }) } -- cgit v1.2.3 From 63a462f37ca584e1a585a69e30823ce25d4d252f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Apr 2020 00:57:47 +0200 Subject: Switch to TryFrom --- crates/ra_assists/src/handlers/add_new.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_assists/src/handlers/add_new.rs') diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 0698cce88..0f9174a29 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs @@ -77,13 +77,13 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option { .text_range() .end(); - Some((start, TextSize::from_usize(1))) + Some((start, TextSize::of("\n"))) }) .unwrap_or_else(|| { buf = generate_impl_text(&strukt, &buf); let start = strukt.syntax().text_range().end(); - (start, TextSize::from_usize(3)) + (start, TextSize::of("\n}\n")) }); edit.set_cursor(start_offset + TextSize::of(&buf) - end_offset); -- cgit v1.2.3