aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-05-20 12:48:31 +0100
committerAleksey Kladov <[email protected]>2020-05-20 12:48:31 +0100
commita622b54ac029994328a99e30ee3169c21de498b7 (patch)
tree9a89e66c0b4f2564f5ec9d9ac061615fdc81eb5f
parent74da16f6f95aec839842d1f920fec9e40b6f80a4 (diff)
Don't set cursor in change_visibility
-rw-r--r--crates/ra_assists/src/handlers/change_visibility.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs
index 1d9b8e645..fbe459c9c 100644
--- a/crates/ra_assists/src/handlers/change_visibility.rs
+++ b/crates/ra_assists/src/handlers/change_visibility.rs
@@ -68,7 +68,6 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
68 68
69 acc.add(AssistId("change_visibility"), "Change visibility to pub(crate)", target, |edit| { 69 acc.add(AssistId("change_visibility"), "Change visibility to pub(crate)", target, |edit| {
70 edit.insert(offset, "pub(crate) "); 70 edit.insert(offset, "pub(crate) ");
71 edit.set_cursor(offset);
72 }) 71 })
73} 72}
74 73
@@ -92,7 +91,6 @@ fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> {
92 target, 91 target,
93 |edit| { 92 |edit| {
94 edit.replace(vis.syntax().text_range(), "pub(crate)"); 93 edit.replace(vis.syntax().text_range(), "pub(crate)");
95 edit.set_cursor(vis.syntax().text_range().start())
96 }, 94 },
97 ); 95 );
98 } 96 }
@@ -104,7 +102,6 @@ fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> {
104 target, 102 target,
105 |edit| { 103 |edit| {
106 edit.replace(vis.syntax().text_range(), "pub"); 104 edit.replace(vis.syntax().text_range(), "pub");
107 edit.set_cursor(vis.syntax().text_range().start());
108 }, 105 },
109 ); 106 );
110 } 107 }
@@ -122,15 +119,15 @@ mod tests {
122 #[test] 119 #[test]
123 fn change_visibility_adds_pub_crate_to_items() { 120 fn change_visibility_adds_pub_crate_to_items() {
124 check_assist(change_visibility, "<|>fn foo() {}", "<|>pub(crate) fn foo() {}"); 121 check_assist(change_visibility, "<|>fn foo() {}", "<|>pub(crate) fn foo() {}");
125 check_assist(change_visibility, "f<|>n foo() {}", "<|>pub(crate) fn foo() {}"); 122 check_assist(change_visibility, "f<|>n foo() {}", "pub(crate) f<|>n foo() {}");
126 check_assist(change_visibility, "<|>struct Foo {}", "<|>pub(crate) struct Foo {}"); 123 check_assist(change_visibility, "<|>struct Foo {}", "<|>pub(crate) struct Foo {}");
127 check_assist(change_visibility, "<|>mod foo {}", "<|>pub(crate) mod foo {}"); 124 check_assist(change_visibility, "<|>mod foo {}", "<|>pub(crate) mod foo {}");
128 check_assist(change_visibility, "<|>trait Foo {}", "<|>pub(crate) trait Foo {}"); 125 check_assist(change_visibility, "<|>trait Foo {}", "<|>pub(crate) trait Foo {}");
129 check_assist(change_visibility, "m<|>od {}", "<|>pub(crate) mod {}"); 126 check_assist(change_visibility, "m<|>od {}", "pub(crate) m<|>od {}");
130 check_assist( 127 check_assist(
131 change_visibility, 128 change_visibility,
132 "unsafe f<|>n foo() {}", 129 "unsafe f<|>n foo() {}",
133 "<|>pub(crate) unsafe fn foo() {}", 130 "pub(crate) unsafe f<|>n foo() {}",
134 ); 131 );
135 } 132 }
136 133