diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index 6f04f0be4e..867a0f0bdc 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 }") } }