From 04a8daaa33ad8aa068ccc24011c0844d06ba0ee7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 21 May 2020 00:46:08 +0200 Subject: Remove unused cursor positions --- crates/ra_ide/src/typing.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index 6f04f0be4..867a0f0bd 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs @@ -111,7 +111,7 @@ fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option Some(SingleFileChange { label: "reindent dot".to_string(), edit: TextEdit::replace(TextRange::new(offset - current_indent_len, offset), target_indent), - cursor_position: Some(offset + target_indent_len - current_indent_len + TextSize::of('.')), + cursor_position: None, }) } @@ -130,7 +130,7 @@ fn on_arrow_typed(file: &SourceFile, offset: TextSize) -> Option Option<(String, SingleFileChange)> { + fn do_type_char(char_typed: char, before: &str) -> Option { let (offset, before) = extract_offset(before); let edit = TextEdit::insert(offset, char_typed.to_string()); let mut before = before.to_string(); @@ -148,21 +148,15 @@ mod tests { let parse = SourceFile::parse(&before); on_char_typed_inner(&parse.tree(), offset, char_typed).map(|it| { it.edit.apply(&mut before); - (before.to_string(), it) + before.to_string() }) } fn type_char(char_typed: char, before: &str, after: &str) { - let (actual, file_change) = do_type_char(char_typed, before) + let actual = do_type_char(char_typed, before) .unwrap_or_else(|| panic!("typing `{}` did nothing", char_typed)); - if after.contains("<|>") { - let (offset, after) = extract_offset(after); - assert_eq_text!(&after, &actual); - assert_eq!(file_change.cursor_position, Some(offset)) - } else { - assert_eq_text!(after, &actual); - } + assert_eq_text!(after, &actual); } fn type_char_noop(char_typed: char, before: &str) { @@ -350,6 +344,6 @@ fn foo() { #[test] fn adds_space_after_return_type() { - type_char('>', "fn foo() -<|>{ 92 }", "fn foo() -><|> { 92 }") + type_char('>', "fn foo() -<|>{ 92 }", "fn foo() -> { 92 }") } } -- cgit v1.2.3