From 4f3bc42349534518940f5a9a4db64287d897c03f Mon Sep 17 00:00:00 2001 From: Simon Vandel Sillesen Date: Sun, 6 Jan 2019 12:24:33 +0100 Subject: add more tests --- crates/ra_editor/src/typing.rs | 55 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs index ceef8b879..528c7b200 100644 --- a/crates/ra_editor/src/typing.rs +++ b/crates/ra_editor/src/typing.rs @@ -306,7 +306,7 @@ mod tests { use super::*; use crate::test_utils::{ add_cursor, assert_eq_text, check_action, extract_offset, extract_range, -}; + }; fn check_join_lines(before: &str, after: &str) { check_action(before, after, |file, offset| { @@ -646,6 +646,7 @@ fn foo() { let actual = result.edit.apply(&before); assert_eq_text!(after, &actual); } + // indent if continuing chain call do_check( r" pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable> { @@ -658,6 +659,58 @@ fn foo() { self.child_impl(db, name) . } +", + ); + + // do not indent if already indented + do_check( + r" + pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable> { + self.child_impl(db, name) + .<|> + } +", + r" + pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable> { + self.child_impl(db, name) + . + } +", + ); + + // indent if the previous line is already indented + do_check( + r" + pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable> { + self.child_impl(db, name) + .first() + .<|> + } +", + r" + pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable> { + self.child_impl(db, name) + .first() + . + } +", + ); + + // don't indent if indent matches previous line + do_check( + r" + pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable> { + self.child_impl(db, name) + .first() + .<|> + } +", + r" + pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable> { + self.child_impl(db, name) + .first() + . + } ", ); } -- cgit v1.2.3