From bf7a35294d92381ce85cbb6e8a300a270a4d6a81 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Sun, 23 Jun 2019 10:41:43 +0900 Subject: Add box postfix completion --- crates/ra_ide_api/src/completion/complete_postfix.rs | 2 ++ ...em__postfix_completion_works_for_trivial_path_expression.snap | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs index 278b1b797..e20a12e2a 100644 --- a/crates/ra_ide_api/src/completion/complete_postfix.rs +++ b/crates/ra_ide_api/src/completion/complete_postfix.rs @@ -51,6 +51,8 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { ) .add_to(acc); postfix_snippet(ctx, "dbg", "dbg!(expr)", &format!("dbg!({})", receiver_text)).add_to(acc); + postfix_snippet(ctx, "box", "Box::new(expr)", &format!("Box::new({})", receiver_text)) + .add_to(acc); } } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap index fcb292596..c1a40b7b4 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap @@ -1,10 +1,17 @@ --- -created: "2019-05-23T22:23:35.118738523Z" +created: "2019-06-23T13:01:08.775536006Z" creator: insta@0.8.1 source: crates/ra_ide_api/src/completion/completion_item.rs expression: kind_completions --- [ + CompletionItem { + label: "box", + source_range: [76; 76), + delete: [72; 76), + insert: "Box::new(bar)", + detail: "Box::new(expr)", + }, CompletionItem { label: "dbg", source_range: [76; 76), -- cgit v1.2.3