aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
authorTimo Freiberg <[email protected]>2020-04-20 17:02:36 +0100
committerTimo Freiberg <[email protected]>2020-04-21 22:04:44 +0100
commit74780a15f65916d08942eb53c43b8e8c0b62cb48 (patch)
treeb34aefbe32e61d7c2630e74cde58060a850093e0 /crates/ra_assists/src
parentba8faf3efc7a3a373571f98569699bbe684779b3 (diff)
Jump to sourceChanges in other files
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/handlers/add_function.rs13
-rw-r--r--crates/ra_assists/src/lib.rs10
2 files changed, 10 insertions, 13 deletions
diff --git a/crates/ra_assists/src/handlers/add_function.rs b/crates/ra_assists/src/handlers/add_function.rs
index b65ded871..9bd46f5dc 100644
--- a/crates/ra_assists/src/handlers/add_function.rs
+++ b/crates/ra_assists/src/handlers/add_function.rs
@@ -907,23 +907,14 @@ mod foo;
907fn main() { 907fn main() {
908 foo::bar<|>() 908 foo::bar<|>()
909} 909}
910
911//- /foo.rs 910//- /foo.rs
912
913", 911",
914 r" 912 r"
915//- /main.rs
916mod foo;
917 913
918fn main() {
919 foo::bar()
920}
921 914
922//- /foo.rs 915pub(crate) fn bar() {
923fn bar() {
924 <|>todo!() 916 <|>todo!()
925} 917}",
926",
927 ) 918 )
928 } 919 }
929 920
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index fb57486cb..ccc95735f 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -197,7 +197,7 @@ mod helpers {
197 use ra_ide_db::{symbol_index::SymbolsDatabase, RootDatabase}; 197 use ra_ide_db::{symbol_index::SymbolsDatabase, RootDatabase};
198 use test_utils::{add_cursor, assert_eq_text, extract_range_or_offset, RangeOrOffset}; 198 use test_utils::{add_cursor, assert_eq_text, extract_range_or_offset, RangeOrOffset};
199 199
200 use crate::{AssistCtx, AssistHandler}; 200 use crate::{AssistCtx, AssistFile, AssistHandler};
201 use hir::Semantics; 201 use hir::Semantics;
202 202
203 pub(crate) fn with_single_file(text: &str) -> (RootDatabase, FileId) { 203 pub(crate) fn with_single_file(text: &str) -> (RootDatabase, FileId) {
@@ -259,7 +259,13 @@ mod helpers {
259 (Some(assist), ExpectedResult::After(after)) => { 259 (Some(assist), ExpectedResult::After(after)) => {
260 let action = assist.0[0].action.clone().unwrap(); 260 let action = assist.0[0].action.clone().unwrap();
261 261
262 let mut actual = action.edit.apply(&text_without_caret); 262 let assisted_file_text = if let AssistFile::TargetFile(file_id) = action.file {
263 db.file_text(file_id).as_ref().to_owned()
264 } else {
265 text_without_caret
266 };
267
268 let mut actual = action.edit.apply(&assisted_file_text);
263 match action.cursor_position { 269 match action.cursor_position {
264 None => { 270 None => {
265 if let RangeOrOffset::Offset(before_cursor_pos) = range_or_offset { 271 if let RangeOrOffset::Offset(before_cursor_pos) = range_or_offset {