From 751562d2f77a7bc3eeeffbf8e53c9f3515fa9653 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 6 Sep 2018 01:19:24 +0300 Subject: better introduce --- crates/libeditor/src/code_actions.rs | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/crates/libeditor/src/code_actions.rs b/crates/libeditor/src/code_actions.rs index ebe70681b..4a07d1bc9 100644 --- a/crates/libeditor/src/code_actions.rs +++ b/crates/libeditor/src/code_actions.rs @@ -109,17 +109,22 @@ pub fn introduce_variable<'a>(file: &'a File, range: TextRange) -> Optionvar_name = 1 + 1; foo(var_name); +}", + |file, range| introduce_variable(file, range).map(|f| f()), + ); + } + #[test] + fn test_intrdoduce_var_expr_stmt() { +check_action_range( + " +fn foo() { + <|>1 + 1<|>; +}", " +fn foo() { + let <|>var_name = 1 + 1; }", |file, range| introduce_variable(file, range).map(|f| f()), ); -- cgit v1.2.3